aboutsummaryrefslogtreecommitdiff
path: root/libc/bionic/spawn.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-11-14 22:31:43 -0800
committerElliott Hughes <enh@google.com>2017-11-14 22:31:43 -0800
commit2b8ab4b5da58105432081ed8302a4364583c2279 (patch)
treef145d820aaf468b3bc77df03370731a892edc5d5 /libc/bionic/spawn.cpp
parent40a5cfa8d11c7a36c546eb9acff19975a99450ce (diff)
Simplify the posix_spawn sigdefault logic.
I don't think there's any observable difference, but this is certainly simpler. Bug: http://b/68707996 Test: ran tests Change-Id: Id9e1a7d40533c90d073ebf391a72bbdfe79627de
Diffstat (limited to 'libc/bionic/spawn.cpp')
-rw-r--r--libc/bionic/spawn.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/libc/bionic/spawn.cpp b/libc/bionic/spawn.cpp
index 3588d0242..061d68c31 100644
--- a/libc/bionic/spawn.cpp
+++ b/libc/bionic/spawn.cpp
@@ -91,19 +91,13 @@ struct __posix_spawnattr {
sigset_t sigdefault;
void Do() {
- bool use_sigdefault = ((flags & POSIX_SPAWN_SETSIGDEF) != 0);
-
- for (int s = 1; s < _NSIG; ++s) {
- struct sigaction sa;
- if (sigaction(s, nullptr, &sa) == -1) _exit(127);
- if (sa.sa_handler == SIG_DFL) continue;
- // POSIX: "Signals set to be caught by the calling process shall be set to the default
- // action in the child process."
+ if ((flags & POSIX_SPAWN_SETSIGDEF) != 0) {
// POSIX: "If POSIX_SPAWN_SETSIGDEF is set ... signals in sigdefault ... shall be set to
// their default actions in the child process."
- if (sa.sa_handler != SIG_IGN || (use_sigdefault && sigismember(&sigdefault, s))) {
- sa.sa_handler = SIG_DFL;
- if (sigaction(s, &sa, nullptr) == -1) _exit(127);
+ struct sigaction sa = {};
+ sa.sa_handler = SIG_DFL;
+ for (int s = 1; s < _NSIG; ++s) {
+ if (sigismember(&sigdefault, s) && sigaction(s, &sa, nullptr) == -1) _exit(127);
}
}