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

A05 test failure (was Re: 5.0.9 eventually...?)

On Aug 10,  7:12am, Ismail Donmez wrote:
} latest git started to fail here on Linux x64:
} ./A05execution.ztst: starting.
} This test takes 5 seconds to fail...
} Test ./A05execution.ztst failed: bad status 2, expected 1 from:
} Was testing: The status of recently exited background jobs is recorded

This apparently has always been a race condition and queuing of signals
in more places simply made it obvious.  I can only reproduce the failed
test on one of the systems where I can try it.

What's happening is that the SIGCHLD for (exit 2) is arriving during the
run of zhandler() for recording the status of (exit 1).  The value of
the global lastval2 is not saved/restored around the signal handling
so when the (exit 1) handler resumes it copies the exit status of the
second child into the bgstatus list as the exit of the first child.

It's fairly easy to make any two of the jobs exchange status by adding
sleep or other delays.

Anyway, turns out this was an ANCIENT bug that the revised queueing
paradigm exposed.

diff --git a/Src/signals.c b/Src/signals.c
index 697c4c5..acdc0bc 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -487,6 +487,12 @@ wait_for_processes(void)
+	/* This is necessary to be sure queueing_enabled > 0 when
+	 * we enter printjob() from update_job(), so that we don't
+	 * decrement to zero in should_report_time() and improperly
+	 * run other handlers in the middle of processing this one */
+	queue_signals();
 	 * Find the process and job containing this pid and
 	 * update it.
@@ -530,6 +536,8 @@ wait_for_processes(void)
 	if (jn && !(jn->stat & (STAT_CURSH|STAT_BUILTIN)) &&
 	    jn - jobtab != thisjob)
 	    addbgstatus(pid, (int)lastval2);
+	unqueue_signals();

Barton E. Schaefer

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