commit 8f26017bb9cb3f38424f50511263cf70e476d98b
parent 8f81d22c989808d3889a7ad6806903adec5ae27b
Author: tjg <tjg>
Date: Thu, 15 Aug 2002 13:45:03 +0000
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:
4 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -802,3 +802,8 @@ Changes since rc-1.5b2
Bug: variables that are sometimes exported (i.e. $prompt and
$version) need to be made exportable if they are inherited from the
environment.
+
+ 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).
diff --git a/acinclude.m4 b/acinclude.m4
@@ -128,21 +128,6 @@ AC_DEFUN(RC_TYPE_SIG_ATOMIC_T, [
])
-dnl Check for sigaction and SA_INTERRUPT
-AC_DEFUN(RC_FUNC_SIGACTION, [
- AC_CACHE_CHECK(for sigaction and SA_INTERRUPT, rc_cv_sa_int,
- AC_TRY_COMPILE([
-#include <signal.h>
- ], [
-struct sigaction foo;
-foo.sa_flags = SA_INTERRUPT;
-sigaction(SIGINT, 0, 0);
- ], rc_cv_sa_int=yes, rc_cv_sa_int=no
- )
- )
-])
-
-
dnl Do we have SysV SIGCLD semantics? In other words, if we set the
dnl action for SIGCLD to SIG_IGN does wait() always say ECHILD? Linux,
dnl of course, is bizarre here. It basically implements the SysV
diff --git a/configure.ac b/configure.ac
@@ -40,7 +40,16 @@ AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_CHECK_TYPE(ssize_t, long)
-AC_CHECK_FUNCS(getgroups lstat setpgrp setrlimit)
+AC_CHECK_FUNCS(getgroups lstat setpgrp setrlimit sigaction)
+
+dnl We prefer system calls that don't restart. If we have sigaction()
+dnl we'll use it. Otherwise, we check whether good ol' signal()
+dnl produces interruptible system calls.
+case "$ac_cv_func_sigaction" in
+no) AC_SYS_RESTARTABLE_SYSCALLS ;;
+esac
+AM_CONDITIONAL(AMC_RESTART, test "$ac_cv_sys_restartable_syscalls" = yes)
+
RC_FUNC_GETGROUPS
RC_FUNC_SIGSETJMP
@@ -55,16 +64,6 @@ RC_TYPE_RLIM_T
RC_TYPE_SIG_ATOMIC_T
-dnl We prefer system calls that don't restart. If we have sigaction()
-dnl and SA_INTERRUPT, we'll use 'em. Otherwise, we check whether good
-dnl ol' signal() produces interruptible system calls.
-RC_FUNC_SIGACTION
-case "$rc_cv_sa_int" in
-yes) AC_DEFINE(HAVE_SA_INTERRUPT) ;;
-no) AC_SYS_RESTARTABLE_SYSCALLS ;;
-esac
-AM_CONDITIONAL(AMC_RESTART, test "$ac_cv_sys_restartable_syscalls" = yes)
-
RC_SYS_V_SIGCLD
dnl Does the kernel handle `#! /interpreter'?
diff --git 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);