summaryrefslogtreecommitdiff
path: root/librt
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2017-11-22 21:30:24 +0100
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2017-11-22 21:31:41 +0100
commit71b3a63b641716165f664cf112be0673a122cea0 (patch)
treee8350273c4889d1067e2eb4824dfaa0358604a6d /librt
parent2fcffe26e815b7125a357c83b59617ab93c16b41 (diff)
librt: fix broken posix_spawn
Fix iteration over signals, synced with GNU C library code and pending patches. Issues found when running dhcpcd with hook scripts. (exit status 127) Reported-By: kapeka <kapeka@bering-uclibc.de>
Diffstat (limited to 'librt')
-rw-r--r--librt/spawn.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/librt/spawn.c b/librt/spawn.c
index 25e3994e1..a2b8e061b 100644
--- a/librt/spawn.c
+++ b/librt/spawn.c
@@ -25,6 +25,7 @@
#include <sys/resource.h>
#include <not-cancel.h>
+#include <internal-signals.h>
#include <spawn.h>
#include "spawn_int.h"
@@ -153,13 +154,32 @@ __spawni(pid_t *pid, const char *file,
int sig;
memset(&sa, 0, sizeof(sa));
- sa.sa_handler = SIG_DFL;
- for (sig = 1; sig <= _NSIG; ++sig) {
- if (sigismember(&attrp->__sd, sig)) {
- if (sigaction(sig, &sa, NULL) != 0)
- goto error;
- }
+ sigset_t hset;
+ sigprocmask (SIG_BLOCK, 0, &hset);
+
+ for (int sig = 1; sig < _NSIG; ++sig) {
+ if ((flags & POSIX_SPAWN_SETSIGDEF)
+ && sigismember (&attrp->__sd, sig))
+ {
+ sa.sa_handler = SIG_DFL;
+ }
+ else if (sigismember (&hset, sig))
+ {
+ if (__is_internal_signal (sig))
+ sa.sa_handler = SIG_IGN;
+ else
+ {
+ __libc_sigaction (sig, 0, &sa);
+ if (sa.sa_handler == SIG_IGN)
+ continue;
+ sa.sa_handler = SIG_DFL;
+ }
+ }
+ else
+ continue;
+
+ __libc_sigaction (sig, &sa, 0);
}
}