*** 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)