summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorcracauer <cracauer@FreeBSD.org>2001-02-06 10:29:34 +0000
committercracauer <cracauer@FreeBSD.org>2001-02-06 10:29:34 +0000
commitee151afe7884d87201360c2733e70c287edfef9d (patch)
tree5ab79f186514320bf8920bce9e5e90e74550a1ca /bin/sh
parent61e9b8f80f914785094ed6ea32f7d563eea2ba3f (diff)
downloadFreeBSD-src-ee151afe7884d87201360c2733e70c287edfef9d.zip
FreeBSD-src-ee151afe7884d87201360c2733e70c287edfef9d.tar.gz
Fix child's SIGSTOP behaviour in scripts.
When a child is receiving SIGSTOP, eval continues with the next command. While that is correct for the interactive case (Control-Z and you get the prompt back), it is wrong for a shellscript, which just continues with the next command, never again waiting for the stopped child. Noted when childs from cronjobs were stopped, just to make more processes (by wosch). The fix is not to return from a job wait when the wait returned for a stopped child while in non-interactive mode. This bahaviour seems to be what bash2 and ksh implement. I tested for correct behaviour for finnaly killing the child with and without forgrounding it first. When not foregrouding before killing, the shell continues with the script, which is what the other shells do as well. Reviewed by: Silence on -current
Diffstat (limited to 'bin/sh')
-rw-r--r--bin/sh/jobs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index 8ba307b..96cc963 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -783,7 +783,8 @@ dowait(block, job)
do {
pid = waitproc(block, &status);
TRACE(("wait returns %d, status=%d\n", pid, status));
- } while (pid == -1 && errno == EINTR && breakwaitcmd == 0);
+ } while ((pid == -1 && errno == EINTR && breakwaitcmd == 0) ||
+ (WIFSTOPPED(status) && !iflag));
in_dowait--;
if (breakwaitcmd != 0) {
breakwaitcmd = 0;
OpenPOWER on IntegriCloud