diff options
| author | tgoodwin <tgoodwin> | 1998-07-21 14:27:42 +0000 |
|---|---|---|
| committer | Toby Goodwin <toby@paccrat.org> | 2015-05-16 21:23:10 +0100 |
| commit | 43c1019eca5e6d67e239cb38d54cd9c359577827 (patch) | |
| tree | 633c36594c73a7e0eec055a172a59ea77c950ddf /signal.c | |
| parent | b79e7f2d747a7ad926e15eb1395616a3babb6671 (diff) | |
fix for Linux with glibc2 so system calls are not restarted
Diffstat (limited to 'signal.c')
| -rw-r--r-- | signal.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -7,6 +7,19 @@ #include "sigmsgs.h" #include "jbwrap.h" +#if HAVE_SA_INTERRUPT +static void (*sys_signal(int signum, void (*handler)(int)))(int) { + struct sigaction new, old; + + new.sa_handler = handler; + new.sa_flags = SA_INTERRUPT; + sigaction(signum, &new, &old); + return old.sa_handler; +} +#else +#define sys_signal signal +#endif + void (*sighandlers[NUMOFSIGNALS])(int); static volatile sig_atomic_t sigcount, caught[NUMOFSIGNALS]; @@ -16,7 +29,7 @@ extern void catcher(int s) { sigcount++; caught[s] = 1; } - signal(s, catcher); + sys_signal(s, catcher); #if READLINE if (rl_active) @@ -59,11 +72,11 @@ extern void (*rc_signal(int s, void (*h)(int)))(int) { sigchk(); old = sighandlers[s]; if (h == SIG_DFL || h == SIG_IGN) { - signal(s, h); sighandlers[s] = h; + sys_signal(s, h); } else { sighandlers[s] = h; - signal(s, catcher); + sys_signal(s, catcher); } return old; } @@ -73,16 +86,16 @@ extern void initsignal() { int i; for (i = 1; i < NUMOFSIGNALS; i++) { - h = signal(i, SIG_DFL); + h = sys_signal(i, SIG_DFL); if (h != SIG_DFL && h != SIG_ERR) - signal(i, h); + sys_signal(i, h); sighandlers[i] = h; } #if HAVE_SYSV_SIGCLD /* Ensure that SIGCLD is not SIG_IGN. Solaris's rshd does this. :-( */ - h = signal(SIGCLD, SIG_DFL); + h = sys_signal(SIGCLD, SIG_DFL); if (h != SIG_IGN && h != SIG_ERR) - signal(SIGCLD, h); + sys_signal(SIGCLD, h); #endif } |