summaryrefslogtreecommitdiff
path: root/libc/signal/bsd_sig.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-10-23 23:23:54 +0000
committerEric Andersen <andersen@codepoet.org>2000-10-23 23:23:54 +0000
commit5606e4d6f92c10af214b54a01db79cf561067e58 (patch)
treef50c5adf765ad7492736b3fb0e9ae669573e4e5e /libc/signal/bsd_sig.c
parent56c9a8402ff4c9004331efc77e5a5fe62aa65014 (diff)
More reorg. A place for everything and everything in its place...
Diffstat (limited to 'libc/signal/bsd_sig.c')
-rw-r--r--libc/signal/bsd_sig.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libc/signal/bsd_sig.c b/libc/signal/bsd_sig.c
new file mode 100644
index 000000000..509de87cb
--- /dev/null
+++ b/libc/signal/bsd_sig.c
@@ -0,0 +1,34 @@
+#define __USE_BSD_SIGNAL
+
+#include <signal.h>
+
+#undef signal
+
+/* The `sig' bit is set if the interrupt on it
+ * is enabled via siginterrupt (). */
+extern sigset_t _sigintr;
+
+__sighandler_t
+__bsd_signal (int sig, __sighandler_t handler)
+{
+ int ret;
+ struct sigaction action, oaction;
+ action.sa_handler = handler;
+ __sigemptyset (&action.sa_mask);
+ if (!__sigismember (&_sigintr, sig)) {
+#ifdef SA_RESTART
+ action.sa_flags = SA_RESTART;
+#else
+ action.sa_flags = 0;
+#endif
+ }
+ else {
+#ifdef SA_INTERRUPT
+ action.sa_flags = SA_INTERRUPT;
+#else
+ action.sa_flags = 0;
+#endif
+ }
+ ret = __sigaction (sig, &action, &oaction);
+ return (ret == -1) ? SIG_ERR : oaction.sa_handler;
+}