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
diff --git a/libc/bionic/spawn.cpp b/libc/bionic/spawn.cpp
index 3588d02..061d68c 100644
--- a/libc/bionic/spawn.cpp
+++ b/libc/bionic/spawn.cpp
@@ -91,19 +91,13 @@
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);
}
}