svn commit: r216208 - head/bin/sh

Jilles Tjoelker jilles at FreeBSD.org
Sun Dec 5 21:53:29 UTC 2010


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++) {


More information about the svn-src-all mailing list