Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: remove ancient signals support



The following patch removes autoconf tests and #ifdef soup associated
with support for systems that only have the old pre-POSIX signal()
function for signal handling. I can't find any currently relevant system
that still relies on this and reliance on sigaction() without autoconf
tests is widespread across other codebases. Does anyone see a reason for
keeping this around?

Oliver

diff --git a/Src/init.c b/Src/init.c
index 0aecb5db9..8c7776c7a 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1386,6 +1386,8 @@ setupshin(char *runscript)
 void
 init_signals(void)
 {
+    struct sigaction act;
+
     sigtrapped = (int *) hcalloc(TRAPCOUNT * sizeof(int));
     siglists = (Eprog *) hcalloc(TRAPCOUNT * sizeof(Eprog));
 
@@ -1399,14 +1401,8 @@ init_signals(void)
 
     intr();
 
-#ifdef POSIX_SIGNALS
-    {
-	struct sigaction act;
-	if (!sigaction(SIGQUIT, NULL, &act) &&
-	    act.sa_handler == SIG_IGN)
-	    sigtrapped[SIGQUIT] = ZSIG_IGNORED;
-    }
-#endif
+    if (!sigaction(SIGQUIT, NULL, &act) && act.sa_handler == SIG_IGN)
+	sigtrapped[SIGQUIT] = ZSIG_IGNORED;
 
 #ifndef QDEBUG
     signal_ignore(SIGQUIT);
diff --git a/Src/signals.c b/Src/signals.c
index d28853ea6..6eecbf7d5 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -91,33 +91,6 @@ mod_export volatile int trap_queueing_enabled, trap_queue_front, trap_queue_rear
 /**/
 mod_export int trap_queue[MAX_QUEUE_SIZE];
 
-/* This is only used on machines that don't understand signal sets.  *
- * On SYSV machines this will represent the signals that are blocked *
- * (held) using sighold.  On machines which can't block signals at   *
- * all, we will simulate this by ignoring them and remembering them  *
- * in this variable.                                                 */
-#if !defined(POSIX_SIGNALS) && !defined(BSD_SIGNALS)
-static sigset_t blocked_set;
-#endif
-
-#ifdef POSIX_SIGNALS
-# define signal_jmp_buf       sigjmp_buf
-# define signal_setjmp(b)     sigsetjmp((b),1)
-# define signal_longjmp(b,n)  siglongjmp((b),(n))
-#else
-# define signal_jmp_buf       jmp_buf
-# define signal_setjmp(b)     setjmp(b)
-# define signal_longjmp(b,n)  longjmp((b),(n))
-#endif
- 
-#ifdef NO_SIGNAL_BLOCKING
-# define signal_process(sig)  signal_ignore(sig)
-# define signal_reset(sig)    install_handler(sig)
-#else
-# define signal_process(sig)  ;
-# define signal_reset(sig)    ;
-#endif
-
 /* Install signal handler for given signal.           *
  * If possible, we want to make sure that interrupted *
  * system calls are not restarted.                    */
@@ -126,10 +99,9 @@ static sigset_t blocked_set;
 mod_export void
 install_handler(int sig)
 {
-#ifdef POSIX_SIGNALS
     struct sigaction act;
  
-    act.sa_handler = (SIGNAL_HANDTYPE) zhandler;
+    act.sa_handler = (void (*)(int)) zhandler;
     sigemptyset(&act.sa_mask);        /* only block sig while in handler */
     act.sa_flags = 0;
 # ifdef SA_INTERRUPT                  /* SunOS 4.x */
@@ -137,27 +109,6 @@ install_handler(int sig)
         act.sa_flags |= SA_INTERRUPT; /* make sure system calls are not restarted */
 # endif
     sigaction(sig, &act, (struct sigaction *)NULL);
-#else
-# ifdef BSD_SIGNALS
-    struct sigvec vec;
- 
-    vec.sv_handler = (SIGNAL_HANDTYPE) zhandler;
-    vec.sv_mask = sigmask(sig);    /* mask out this signal while in handler    */
-#  ifdef SV_INTERRUPT
-    vec.sv_flags = SV_INTERRUPT;   /* make sure system calls are not restarted */
-#  endif
-    sigvec(sig, &vec, (struct sigvec *)NULL);
-# else
-#  ifdef SYSV_SIGNALS
-    /* we want sigset rather than signal because it will   *
-     * block sig while in handler.  signal usually doesn't */
-    sigset(sig, zhandler);
-#  else  /* NO_SIGNAL_BLOCKING (bummer) */
-    signal(sig, zhandler);
-
-#  endif /* SYSV_SIGNALS  */
-# endif  /* BSD_SIGNALS   */
-#endif   /* POSIX_SIGNALS */
 }
 
 /* enable ^C interrupts */
@@ -219,50 +170,17 @@ signal_mask(int sig)
 /* Block the signals in the given signal *
  * set. Return the old signal set.       */
 
-/**/
-#ifndef BSD_SIGNALS
-
 /**/
 mod_export sigset_t
 signal_block(sigset_t set)
 {
     sigset_t oset;
  
-#ifdef POSIX_SIGNALS
     sigprocmask(SIG_BLOCK, &set, &oset);
 
-#else
-# ifdef SYSV_SIGNALS
-    int i;
- 
-    oset = blocked_set;
-    for (i = 1; i <= NSIG; ++i) {
-        if (sigismember(&set, i) && !sigismember(&blocked_set, i)) {
-            sigaddset(&blocked_set, i);
-            sighold(i);
-        }
-    }
-# else  /* NO_SIGNAL_BLOCKING */
-/* We will just ignore signals if the system doesn't have *
- * the ability to block them.                             */
-    int i;
-
-    oset = blocked_set;
-    for (i = 1; i <= NSIG; ++i) {
-        if (sigismember(&set, i) && !sigismember(&blocked_set, i)) {
-            sigaddset(&blocked_set, i);
-            signal_ignore(i);
-        }
-   }
-# endif /* SYSV_SIGNALS */
-#endif /* POSIX_SIGNALS */
- 
     return oset;
 }
 
-/**/
-#endif /* BSD_SIGNALS */
-
 /* Unblock the signals in the given signal *
  * set. Return the old signal set.         */
 
@@ -272,39 +190,7 @@ signal_unblock(sigset_t set)
 {
     sigset_t oset;
 
-#ifdef POSIX_SIGNALS
     sigprocmask(SIG_UNBLOCK, &set, &oset);
-#else
-# ifdef BSD_SIGNALS
-    sigfillset(&oset);
-    oset = sigsetmask(oset);
-    sigsetmask(oset & ~set);
-# else
-#  ifdef SYSV_SIGNALS
-    int i;
- 
-    oset = blocked_set;
-    for (i = 1; i <= NSIG; ++i) {
-        if (sigismember(&set, i) && sigismember(&blocked_set, i)) {
-            sigdelset(&blocked_set, i);
-            sigrelse(i);
-        }
-    }
-#  else  /* NO_SIGNAL_BLOCKING */
-/* On systems that can't block signals, we are just ignoring them.  So *
- * to unblock signals, we just reenable the signal handler for them.   */
-    int i;
-
-    oset = blocked_set;
-    for (i = 1; i <= NSIG; ++i) {
-        if (sigismember(&set, i) && sigismember(&blocked_set, i)) {
-            sigdelset(&blocked_set, i);
-            install_handler(i);
-        }
-   }
-#  endif /* SYSV_SIGNALS  */
-# endif  /* BSD_SIGNALS   */
-#endif   /* POSIX_SIGNALS */
  
     return oset;
 }
@@ -318,61 +204,19 @@ signal_setmask(sigset_t set)
 {
     sigset_t oset;
  
-#ifdef POSIX_SIGNALS
     sigprocmask(SIG_SETMASK, &set, &oset);
-#else
-# ifdef BSD_SIGNALS
-    oset = sigsetmask(set);
-# else
-#  ifdef SYSV_SIGNALS
-    int i;
- 
-    oset = blocked_set;
-    for (i = 1; i <= NSIG; ++i) {
-        if (sigismember(&set, i) && !sigismember(&blocked_set, i)) {
-            sigaddset(&blocked_set, i);
-            sighold(i);
-        } else if (!sigismember(&set, i) && sigismember(&blocked_set, i)) {
-            sigdelset(&blocked_set, i);
-            sigrelse(i);
-        }
-    }
-#  else  /* NO_SIGNAL_BLOCKING */
-    int i;
-
-    oset = blocked_set;
-    for (i = 1; i < NSIG; ++i) {
-        if (sigismember(&set, i) && !sigismember(&blocked_set, i)) {
-            sigaddset(&blocked_set, i);
-            signal_ignore(i);
-        } else if (!sigismember(&set, i) && sigismember(&blocked_set, i)) {
-            sigdelset(&blocked_set, i);
-            install_handler(i);
-        }
-    }
-#  endif /* SYSV_SIGNALS  */
-# endif  /* BSD_SIGNALS   */
-#endif   /* POSIX_SIGNALS */
  
     return oset;
 }
 
-#if defined(NO_SIGNAL_BLOCKING)
-static int suspend_longjmp = 0;
-static signal_jmp_buf suspend_jmp_buf;
-#endif
-
 /**/
 int
 signal_suspend(UNUSED(int sig), int wait_cmd)
 {
     int ret;
 
-#if defined(POSIX_SIGNALS) || defined(BSD_SIGNALS)
     sigset_t set;
-# if defined(POSIX_SIGNALS) && defined(BROKEN_POSIX_SIGSUSPEND)
     sigset_t oset;
-# endif
 
     sigemptyset(&set);
 
@@ -384,9 +228,7 @@ signal_suspend(UNUSED(int sig), int wait_cmd)
     if (!(wait_cmd || isset(TRAPSASYNC) ||
 	  (sigtrapped[SIGINT] & ~ZSIG_IGNORED)))
 	sigaddset(&set, SIGINT);
-#endif /* POSIX_SIGNALS || BSD_SIGNALS */
 
-#ifdef POSIX_SIGNALS
 # ifdef BROKEN_POSIX_SIGSUSPEND
     sigprocmask(SIG_SETMASK, &set, &oset);
     ret = pause();
@@ -394,26 +236,6 @@ signal_suspend(UNUSED(int sig), int wait_cmd)
 # else /* not BROKEN_POSIX_SIGSUSPEND */
     ret = sigsuspend(&set);
 # endif /* BROKEN_POSIX_SIGSUSPEND */
-#else /* not POSIX_SIGNALS */
-# ifdef BSD_SIGNALS
-    ret = sigpause(set);
-# else
-#  ifdef SYSV_SIGNALS
-    ret = sigpause(sig);
-
-#  else  /* NO_SIGNAL_BLOCKING */
-    /* need to use signal_longjmp to make this race-free *
-     * between the child_unblock() and pause()           */
-    if (signal_setjmp(suspend_jmp_buf) == 0) {
-        suspend_longjmp = 1;   /* we want to signal_longjmp after catching signal */
-        child_unblock();       /* do we need to do wait_cmd stuff as well?             */
-        ret = pause();
-    }
-    suspend_longjmp = 0;       /* turn off using signal_longjmp since we are past *
-                                * the pause() function.                           */
-#  endif /* SYSV_SIGNALS  */
-# endif  /* BSD_SIGNALS   */
-#endif   /* POSIX_SIGNALS */
 
     return ret;
 }
@@ -586,33 +408,12 @@ zhandler(int sig)
 {
     sigset_t newmask, oldmask;
 
-#if defined(NO_SIGNAL_BLOCKING)
-    int do_jump;
-    signal_jmp_buf jump_to;
-#endif
- 
     last_signal = sig;
-    signal_process(sig);
  
     sigfillset(&newmask);
     /* Block all signals temporarily           */
     oldmask = signal_block(newmask);
  
-#if defined(NO_SIGNAL_BLOCKING)
-    /* do we need to longjmp to signal_suspend */
-    do_jump = suspend_longjmp;
-    /* In case a SIGCHLD somehow arrives       */
-    suspend_longjmp = 0;
-
-    /* Traps can cause nested signal_suspend()  */
-    if (sig == SIGCHLD) {
-        if (do_jump) {
-	    /* Copy suspend_jmp_buf                    */
-            jump_to = suspend_jmp_buf;
-	}
-    }
-#endif
-
     /* Are we queueing signals now?      */
     if (queueing_enabled) {
         int temp_rear = ++queue_rear % MAX_QUEUE_SIZE;
@@ -627,7 +428,6 @@ zhandler(int sig)
 	    /* save current signal mask        */
             signal_mask_queue[queue_rear] = oldmask;
         }
-        signal_reset(sig);
         return;
     }
  
@@ -704,14 +504,6 @@ zhandler(int sig)
         break;
     }   /* end of switch(sig) */
  
-    signal_reset(sig);
-
-/* This is used to make signal_suspend() race-free */
-#if defined(NO_SIGNAL_BLOCKING)
-    if (do_jump)
-        signal_longjmp(jump_to, 1);
-#endif
-
 } /* handler */
 
  
diff --git a/Src/signals.h b/Src/signals.h
index 7910f6b79..a9c12679f 100644
--- a/Src/signals.h
+++ b/Src/signals.h
@@ -27,8 +27,6 @@
  *
  */
 
-#define SIGNAL_HANDTYPE void (*)(int)
-
 #ifndef HAVE_KILLPG
 # define killpg(pgrp,sig) kill(-(pgrp),sig)
 #endif
@@ -51,20 +49,6 @@
 # define SV_INTERRUPT SV_BSDSIG
 #endif
 
-/* If not a POSIX machine, then we create our *
- * own POSIX style signal sets functions.     */
-#ifndef POSIX_SIGNALS
-# define sigemptyset(s)    (*(s) = 0)
-# if NSIG == 32
-#  define sigfillset(s)    (*(s) = ~(sigset_t)0, 0)
-# else
-#  define sigfillset(s)    (*(s) = (1 << NSIG) - 1, 0)
-# endif
-# define sigaddset(s,n)    (*(s) |=  (1 << ((n) - 1)), 0)
-# define sigdelset(s,n)    (*(s) &= ~(1 << ((n) - 1)), 0)
-# define sigismember(s,n)  ((*(s) & (1 << ((n) - 1))) != 0)
-#endif   /* ifndef POSIX_SIGNALS */
- 
 #define child_block()      signal_block(sigchld_mask)
 #define child_unblock()    signal_unblock(sigchld_mask)
 
diff --git a/configure.ac b/configure.ac
index a88101f2b..eab95105c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1483,35 +1483,6 @@ case $host_os in
   darwin1[0-5]*) AC_DEFINE(SETENV_MANGLES_EQUAL) ;;
 esac
 
-dnl -------------
-dnl CHECK SIGNALS
-dnl -------------
-dnl What style of signal do you have (POSIX, BSD, or SYSV)?
-AH_TEMPLATE([POSIX_SIGNALS],
-[Define to 1 if you use POSIX style signal handling.])
-AH_TEMPLATE([BSD_SIGNALS],
-[Define to 1 if you use BSD style signal handling (and can block signals).])
-AH_TEMPLATE([SYSV_SIGNALS],
-[Define to 1 if you use SYS style signal handling (and can block signals).])
-AH_TEMPLATE([NO_SIGNAL_BLOCKING],
-[Define to 1 if you have no signal blocking at all (bummer).])
-AC_MSG_CHECKING(what style of signals to use)
-if test x$ac_cv_func_sigaction = xyes && test x$ac_cv_func_sigprocmask = xyes; then
-  signals_style=POSIX_SIGNALS
-  AC_DEFINE(POSIX_SIGNALS)
-elif test x$ac_cv_func_sigblock = xyes && test x$ac_cv_func_sigsetmask = xyes; then
-  signals_style=BSD_SIGNALS
-  AC_DEFINE(BSD_SIGNALS)
-elif test x$ac_cv_func_sighold = xyes && test x$ac_cv_func_sigrelse = xyes; then
-  signals_style=SYSV_SIGNALS
-  AC_DEFINE(SYSV_SIGNALS)
-else
-  signals_style=NO_SIGNAL_BLOCKING
-  AC_DEFINE(NO_SIGNAL_BLOCKING)
-fi
-AC_DEFINE_UNQUOTED($signals_style)
-AC_MSG_RESULT($signals_style)
-
 dnl Where is <signal.h> located?  Needed as input for signals.awk
 AC_CACHE_CHECK(where signal.h is located, zsh_cv_path_signal_h,
 [dnl Look at the output from the preprocessor.
@@ -2324,7 +2295,6 @@ dnl for instance, BeOS R4.51 is broken.
 dnl -----------
 AH_TEMPLATE([BROKEN_POSIX_SIGSUSPEND],
 Define to 1 if sigsuspend() is broken, ie BeOS R4.51.])
-if test x$signals_style = xPOSIX_SIGNALS; then
     AC_CACHE_CHECK(if POSIX sigsuspend() works,
     zsh_cv_sys_sigsuspend,
     [AC_RUN_IFELSE([AC_LANG_SOURCE([[
@@ -2356,7 +2326,6 @@ int main() {
     if test x$zsh_cv_sys_sigsuspend = xno; then
       AC_DEFINE(BROKEN_POSIX_SIGSUSPEND)
     fi
-fi
 
 dnl -----------
 dnl if found tcsetpgrp, test to see if it actually works




Messages sorted by: Reverse Date, Date, Thread, Author