Bruno Haible <[email protected]> writes:
> In the CI, I see a test failure
> FAIL: tests/factor/factor-parallel
> on Solaris 11.4 and OpenBSD, yesterday (Oct 27) that was not present
> a week earlier (Oct 20).
>
> Guessing from the error message in the log below, it's caused by the
> 'split' changes last week.
Thanks.
That would have certainly be easier to debug if posix_spawn could have
the child exit with an exit code other than 127. I spent a little too
long thinking $PATH was ignored or something like that.
The actual issue was that Gnulib's posix_spawn calls sigismember in the
child process with NSIG. On OpenBSD and Solaris this causes it to return
-1 and set errno to EINVAL. The child process has nothing to do but
_exit (127) in that case. Here is the test program I used:
$ cat main.c
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
int
main (void)
{
sigset_t set;
sigemptyset (&set);
errno = 0;
if (sigismember (&set, NSIG) != 0)
{
fprintf (stderr, "%s\n", strerror (errno));
return 0;
}
return 0;
}
$ cc main.c
$ ./a.out
Invalid argument
That was the result I saw on both OpenBSD and Solaris.
I pushed the attatched patch to Gnulib and updated the submodule in
Coreutils [1] after confirming it fixed things on OpenBSD. I didn't test
it on Solaris, but based on the test program I'm 99% sure it was the
same issue.
Collin
[1]
https://github.com/coreutils/coreutils/commit/7bd932c34e76cdb146c72d47c23c51c7065a3b3d
>From f0b32e7445a8f246726ae0593e48921272bb2481 Mon Sep 17 00:00:00 2001
Message-ID: <f0b32e7445a8f246726ae0593e48921272bb2481.1761723394.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Wed, 29 Oct 2025 00:08:56 -0700
Subject: [PATCH] posix_spawn: Don't give sigismember an invalid signal number.
This caused the child process to exit with a 127 exit status on OpenBSD
and Solaris.
* lib/spawni.c (__spawni): Use < instead of <= when comparing the signal
number to NSIG.
---
ChangeLog | 8 ++++++++
lib/spawni.c | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index b475160780..1a0994fda2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-10-29 Collin Funk <[email protected]>
+
+ posix_spawn: Don't give sigismember an invalid signal number.
+ This caused the child process to exit with a 127 exit status on OpenBSD
+ and Solaris.
+ * lib/spawni.c (__spawni): Use < instead of <= when comparing the signal
+ number to NSIG.
+
2025-10-28 Paul Eggert <[email protected]>
openat2: port O_TMPFILE check to non-GNU/Linux
diff --git a/lib/spawni.c b/lib/spawni.c
index 34c16445fc..a1f3f84a98 100644
--- a/lib/spawni.c
+++ b/lib/spawni.c
@@ -927,7 +927,7 @@ __spawni (pid_t *pid, const char *file,
memset (&sa, '\0', sizeof (sa));
sa.sa_handler = SIG_DFL;
- for (sig = 1; sig <= NSIG; ++sig)
+ for (sig = 1; sig < NSIG; ++sig)
if (sigismember (&attrp->_sd, sig) != 0
&& sigaction (sig, &sa, NULL) != 0)
_exit (SPAWN_ERROR);
--
2.51.1