summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/jobs.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f2e0d04e..428122b72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2008-03-25  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 24733: Src/jobs.c: wait shouldn't return immediately on
+	a signal unless it's trapped (bug in 22281).
+
 	* 24732: Src/Builtins/sched.c: not enough space for ztrftime
 	string with multibyte characters.
 
diff --git a/Src/jobs.c b/Src/jobs.c
index 9bdc602de..1b3d37c63 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1170,7 +1170,8 @@ waitforpid(pid_t pid, int wait_cmd)
 
 	last_signal = -1;
 	signal_suspend(SIGCHLD);
-	if (last_signal != SIGCHLD && wait_cmd) {
+	if (last_signal != SIGCHLD && wait_cmd && last_signal >= 0 &&
+	    (sigtrapped[last_signal] & ZSIG_TRAPPED)) {
 	    /* wait command interrupted, but no error: return */
 	    restore_queue_signals(q);
 	    return 128 + last_signal;
@@ -1208,7 +1209,8 @@ zwaitjob(int job, int wait_cmd)
 	       !(jn->stat & STAT_DONE) &&
 	       !(interact && (jn->stat & STAT_STOPPED))) {
 	    signal_suspend(SIGCHLD);
-	    if (last_signal != SIGCHLD && wait_cmd)
+	    if (last_signal != SIGCHLD && wait_cmd && last_signal >= 0 &&
+		(sigtrapped[last_signal] & ZSIG_TRAPPED))
 	    {
 		/* builtin wait interrupted by trapped signal */
 		restore_queue_signals(q);