diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 2fd7aaa4e7d6..ebf5ed8f900c 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -741,9 +741,6 @@ forkshell(struct job *jp, union node *n, int mode) TRACE(("Child shell %d\n", (int)getpid())); wasroot = rootshell; rootshell = 0; - for (i = njobs, p = jobtab ; --i >= 0 ; p++) - if (p->used) - freejob(p); closescript(); INTON; clear_traps(); @@ -785,6 +782,11 @@ forkshell(struct job *jp, union node *n, int mode) } } #endif + INTOFF; + for (i = njobs, p = jobtab ; --i >= 0 ; p++) + if (p->used) + freejob(p); + INTON; if (wasroot && iflag) { setsignal(SIGINT); setsignal(SIGQUIT);