summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authortjg <tjg>2002-08-15 13:45:03 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:22 +0100
commit8f26017bb9cb3f38424f50511263cf70e476d98b (patch)
treeea09b06bf2fb9cc7a9dcfcf287f309ff1cd04dce /signal.c
parent8f81d22c989808d3889a7ad6806903adec5ae27b (diff)
Portability: don't call sigaction() for SIGKILL or SIGCONT; don't
hand a garbage signal mask to sigaction() (thanks Jeremy Fitzhardinge). Also, remove use of SA_INTERRUPT (SUSv3, BSD, etc. have SA_RESTART with the inverted meaning).
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/signal.c b/signal.c
index de06633..dfdc8d0 100644
--- a/signal.c
+++ b/signal.c
@@ -8,17 +8,18 @@
#include "sigmsgs.h"
#include "jbwrap.h"
-#if HAVE_SA_INTERRUPT
+#if HAVE_SIGACTION
static void (*sys_signal(int signum, void (*handler)(int)))(int) {
struct sigaction new, old;
new.sa_handler = handler;
- new.sa_flags = SA_INTERRUPT;
+ new.sa_flags = 0; /* clear SA_RESTART */
+ sigfillset(&new.sa_mask);
sigaction(signum, &new, &old);
return old.sa_handler;
}
#else
-#define sys_signal signal
+#define sys_signal(sig, func) (signal((sig), (func)))
#endif
void (*sighandlers[NUMOFSIGNALS])(int);
@@ -40,7 +41,7 @@ extern void catcher(int s) {
#if HAVE_RESTARTABLE_SYSCALLS
if (slow) {
siglongjmp(slowbuf.j, s);
-}
+ }
#endif
}
@@ -96,6 +97,12 @@ extern void initsignal() {
#endif
for (i = 1; i < NUMOFSIGNALS; i++) {
+#ifdef SIGKILL
+ if (i == SIGKILL) continue;
+#endif
+#ifdef SIGCONT
+ if (i == SIGCONT) continue;
+#endif
h = sys_signal(i, SIG_IGN);
if (h != SIG_IGN && h != SIG_ERR)
sys_signal(i, h);