components/ksh93/patches/155-CR7178717.patch
changeset 4305 90493abe0c5c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ksh93/patches/155-CR7178717.patch	Mon May 18 14:11:16 2015 -0700
@@ -0,0 +1,54 @@
+*** INIT.2011-02-08/src/cmd/ksh93/sh/jobs.c	Tue Jul 10 17:37:30 2012
+--- ./jobs.c	Tue Jul 10 18:59:39 2012
+***************
+*** 1969,1985 ****
+  	register struct back_save *bp = (struct back_save*)ptr;
+  	register struct process *pw, *px, *pwnext;
+  	struct jobsave *jpnext;
+  	job_lock();
+! 	for(jp=bck.list; jp; jp=jpnext)
+! 	{
+  		jpnext = jp->next;
+! 		if(jp->curenv != sh.curenv || jp->pid==sh.spid)
+! 		{
+! 			jp->next = bp->list;
+! 			bp->list = jp;
+! 			bp->count++;
+! 		}
+! 		else
+  			job_chksave(jp->pid);
+  	}
+  	for(pw=job.pwlist; pw; pw=pwnext)
+--- 1969,2000 ----
+  	register struct back_save *bp = (struct back_save*)ptr;
+  	register struct process *pw, *px, *pwnext;
+  	struct jobsave *jpnext;
++ 
+  	job_lock();
+! 	for(jp = bck.list; jp != NULL; jp = jpnext) {
+  		jpnext = jp->next;
+! 		if (jp->curenv != sh.curenv || jp->pid == sh.spid) {
+! 			struct jobsave *jp2, *jp2next;
+! 			/*
+! 			 * We may have same pid in both saved list and current
+! 			 * list. We discard the old jobsave by copying the new
+! 			 * one.
+! 			 */
+! 			for (jp2 = bp->list; jp2 != NULL; jp2 = jp2->next) {
+! 				if (jp->pid == jp2->pid)
+! 					break;
+! 			}
+! 			if (jp2 != NULL) {
+! 				jp2next = jp2->next;
+! 				*jp2 = *jp;
+! 				jp2->next = jp2next;
+! 				job_chksave(jp2->pid);
+! 			} else {
+! 				jp->next = bp->list;
+! 				bp->list = jp;
+! 				bp->count++;
+! 			}
+! 		} else
+  			job_chksave(jp->pid);
+  	}
+  	for(pw=job.pwlist; pw; pw=pwnext)