summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/jobs.c11
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 7bbcb2add..80013481e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-10-13  Peter Stephenson  <pws@csr.com>
 
+	* 21872: Src/jobs.c: job table wasn't cleared properly in
+	subshells, possibly causing shell to hang; more efficient
+	search for free job entry; don't record current job for
+	use in saved job table.
+
 	* 21871: Src/exec.c, Src/glob.c, Src/params.c, Src/subst.c,
 	Src/utils.c, Src/zsh.h, Src/ztype.h, Src/Zle/compcore.c,
 	Src/Zle/compctl.c, Src/Zle/zle_tricky.c: replace INULL() with
diff --git a/Src/jobs.c b/Src/jobs.c
index 9d7d2aace..96250e84f 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1213,9 +1213,14 @@ clearjobtab(int monitor)
 	int sz = oldmaxjob * sizeof(struct job);
 	oldjobtab = (struct job *)zalloc(sz);
 	memcpy(oldjobtab, jobtab, sz);
+
+	/* Don't report any job we're part of */
+	if (thisjob != -1 && thisjob < oldmaxjob)
+	    memset(oldjobtab+thisjob, 0, sizeof(struct job));
     }
 
-    memset(jobtab, 0, sizeof(jobtab)); /* zero out table */
+    memset(jobtab, 0, jobtabsize * sizeof(struct job)); /* zero out table */
+    maxjob = 0;
 }
 
 static int initnewjob(int i)
@@ -1241,9 +1246,11 @@ initjob(void)
 {
     int i;
 
-    for (i = 1; i < jobtabsize; i++)
+    for (i = 1; i <= maxjob; i++)
 	if (!jobtab[i].stat)
 	    return initnewjob(i);
+    if (maxjob + 1 < jobtabsize)
+	return initnewjob(maxjob+1);
 
     if (expandjobtab())
 	return initnewjob(i);