Date: Sun, 5 Dec 2010 21:53:29 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r216208 - head/bin/sh Message-ID: <201012052153.oB5LrTVN009519@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sun Dec 5 21:53:29 2010 New Revision: 216208 URL: http://svn.freebsd.org/changeset/base/216208 Log: 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. Modified: head/bin/sh/jobs.c Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Sun Dec 5 21:53:12 2010 (r216207) +++ head/bin/sh/jobs.c Sun Dec 5 21:53:29 2010 (r216208) @@ -766,7 +766,7 @@ forkshell(struct job *jp, union node *n, 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++) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012052153.oB5LrTVN009519>