about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-10-13 17:49:59 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-10-13 17:49:59 +0000
commit4a2f8d92e7c3ced677c0a4257c3e017bdf6c00d6 (patch)
treea0af99885b8a170e4f6fd56d5104b9c97788b310 /Src
parent3c37057c34d975ada2e9e6590845732677e77104 (diff)
downloadzsh-4a2f8d92e7c3ced677c0a4257c3e017bdf6c00d6.tar.gz
zsh-4a2f8d92e7c3ced677c0a4257c3e017bdf6c00d6.tar.xz
zsh-4a2f8d92e7c3ced677c0a4257c3e017bdf6c00d6.zip
21872: job accounting in subshells was screwy
Diffstat (limited to 'Src')
-rw-r--r--Src/jobs.c11
1 files changed, 9 insertions, 2 deletions
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);