From 506e81b852532c0c9a46364645396675b03e2c38 Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 5 Dec 2010 21:53:29 +0000 Subject: sh: Avoid marking a job as done before it is fully created. In r208489, I added code to reap zombies when forking new processes, to limit the amount of zombies. However, this can lead to marking a job as done or stopped if it consists of multiple processes and the first process ends very quickly. Fix this by only checking for zombies before forking the first process of a job and not marking any jobs without processes as done or stopped. --- bin/sh/jobs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/sh') diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 1b7a6d4..994c064 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -766,7 +766,7 @@ forkshell(struct job *jp, union node *n, int mode) TRACE(("forkshell(%%%td, %p, %d) called\n", jp - jobtab, (void *)n, mode)); INTOFF; - if (mode == FORK_BG) + if (mode == FORK_BG && (jp == NULL || jp->nprocs == 0)) checkzombies(); flushall(); pid = fork(); @@ -980,7 +980,7 @@ dowait(int block, struct job *job) INTOFF; thisjob = NULL; for (jp = jobtab ; jp < jobtab + njobs ; jp++) { - if (jp->used) { + if (jp->used && jp->nprocs > 0) { done = 1; stopped = 1; for (sp = jp->ps ; sp < jp->ps + jp->nprocs ; sp++) { -- cgit v1.1