about summary refs log tree commit diff
path: root/Src/signals.c
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2009-07-20 04:38:56 +0000
committerBart Schaefer <barts@users.sourceforge.net>2009-07-20 04:38:56 +0000
commitbda90c969f009332956adee965fe00c420f5f7de (patch)
treeb29b21cf2be47f0473a580cfa9ae7514948110d7 /Src/signals.c
parent606cfb5a5e65c80d88fc90169200cea404c16796 (diff)
downloadzsh-bda90c969f009332956adee965fe00c420f5f7de.tar.gz
zsh-bda90c969f009332956adee965fe00c420f5f7de.tar.xz
zsh-bda90c969f009332956adee965fe00c420f5f7de.zip
27159: restore pre-23067 behavior of SIGINT outside a "wait", so that
foreground jobs that handle or ignore interrupts are not orphaned.
Diffstat (limited to 'Src/signals.c')
-rw-r--r--Src/signals.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/Src/signals.c b/Src/signals.c
index 723b121a8..4bc1de016 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -342,29 +342,38 @@ static signal_jmp_buf suspend_jmp_buf;
 
 /**/
 int
-signal_suspend(UNUSED(int sig))
+signal_suspend(UNUSED(int sig), int wait_cmd)
 {
     int ret;
- 
-#ifdef POSIX_SIGNALS
+
+#if defined(POSIX_SIGNALS) || defined(BSD_SIGNALS)
     sigset_t set;
-#ifdef BROKEN_POSIX_SIGSUSPEND
+# if defined(POSIX_SIGNALS) && defined(BROKEN_POSIX_SIGSUSPEND)
     sigset_t oset;
-#endif /* BROKEN_POSIX_SIGSUSPEND */
+# endif
 
     sigemptyset(&set);
-#ifdef BROKEN_POSIX_SIGSUSPEND
+
+    /* SIGINT from the terminal driver needs to interrupt "wait"
+     * and to cause traps to fire, but otherwise should not be
+     * handled by the shell until after any foreground job has
+     * a chance to decide whether to exit on that signal.
+     */
+    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);
     pause();
     sigprocmask(SIG_SETMASK, &oset, NULL);
-#else /* not BROKEN_POSIX_SIGSUSPEND */
+# else /* not BROKEN_POSIX_SIGSUSPEND */
     ret = sigsuspend(&set);
-#endif /* BROKEN_POSIX_SIGSUSPEND */
+# endif /* BROKEN_POSIX_SIGSUSPEND */
 #else /* not POSIX_SIGNALS */
 # ifdef BSD_SIGNALS
-    sigset_t set;
-
-    sigemptyset(&set);
     ret = sigpause(set);
 # else
 #  ifdef SYSV_SIGNALS