Rewrite system(3) to use posix_spawn(3).
We saw crashes from pthread_exit+debuggerd on LP32
(https://issuetracker.google.com/72291624), and it seems like the
equivalent problem should exist with system(3). I fixed posix_spawn(3)
as part of that bug, so the easiest fix is probably to reuse that.
Bug: http://b/72470344
Test: ran tests
Change-Id: I05f838706f2b4a14ac3ee21292833e6c8579b0d4
diff --git a/libc/private/ScopedSignalBlocker.h b/libc/private/ScopedSignalBlocker.h
index 7582068..d1cf629 100644
--- a/libc/private/ScopedSignalBlocker.h
+++ b/libc/private/ScopedSignalBlocker.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef SCOPED_SIGNAL_BLOCKER_H
-#define SCOPED_SIGNAL_BLOCKER_H
+#pragma once
#include <signal.h>
@@ -23,10 +22,18 @@
class ScopedSignalBlocker {
public:
+ // Block all signals.
explicit ScopedSignalBlocker() {
sigset64_t set;
sigfillset64(&set);
- sigprocmask64(SIG_SETMASK, &set, &old_set_);
+ sigprocmask64(SIG_BLOCK, &set, &old_set_);
+ }
+
+ // Block just the specified signal.
+ explicit ScopedSignalBlocker(int signal) {
+ sigset64_t set = {};
+ sigaddset64(&set, signal);
+ sigprocmask64(SIG_BLOCK, &set, &old_set_);
}
~ScopedSignalBlocker() {
@@ -37,10 +44,7 @@
sigprocmask64(SIG_SETMASK, &old_set_, nullptr);
}
- private:
sigset64_t old_set_;
DISALLOW_COPY_AND_ASSIGN(ScopedSignalBlocker);
};
-
-#endif