Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Unified Diff: fusl/src/signal/sigset.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/signal/sigrtmin.c ('k') | fusl/src/signal/sigsetjmp.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/signal/sigset.c
diff --git a/fusl/src/signal/sigset.c b/fusl/src/signal/sigset.c
new file mode 100644
index 0000000000000000000000000000000000000000..0d7b4564677b8f18d0b10979eb937086cd952007
--- /dev/null
+++ b/fusl/src/signal/sigset.c
@@ -0,0 +1,27 @@
+#include <signal.h>
+
+void (*sigset(int sig, void (*handler)(int)))(int)
+{
+ struct sigaction sa, sa_old;
+ sigset_t mask;
+
+ sigemptyset(&mask);
+ if (sigaddset(&mask, sig) < 0)
+ return SIG_ERR;
+
+ if (handler == SIG_HOLD) {
+ if (sigaction(sig, 0, &sa_old) < 0)
+ return SIG_ERR;
+ if (sigprocmask(SIG_BLOCK, &mask, &mask) < 0)
+ return SIG_ERR;
+ } else {
+ sa.sa_handler = handler;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+ if (sigaction(sig, &sa, &sa_old) < 0)
+ return SIG_ERR;
+ if (sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0)
+ return SIG_ERR;
+ }
+ return sigismember(&mask, sig) ? SIG_HOLD : sa_old.sa_handler;
+}
« no previous file with comments | « fusl/src/signal/sigrtmin.c ('k') | fusl/src/signal/sigsetjmp.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698