diff options
author | tjr <tjr@FreeBSD.org> | 2002-08-18 06:43:44 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-08-18 06:43:44 +0000 |
commit | 2f2bf8ffc0ae7c92c322a28e5781db15fbca6226 (patch) | |
tree | 01173b17f3d6e2cf7bc62250fdf4228b7f941f5e | |
parent | a87152b56061e8a50c4a1aa30087ab5414747caa (diff) | |
download | FreeBSD-src-2f2bf8ffc0ae7c92c322a28e5781db15fbca6226.zip FreeBSD-src-2f2bf8ffc0ae7c92c322a28e5781db15fbca6226.tar.gz |
Avoid accessing the current job's process table in the child part of
forkshell() after it has been freed. This caused mysterious behaviour
when anything but the first command in a pipeline tried to access the
terminal when the `junk' malloc() option was enabled (which is the default).
-rw-r--r-- | bin/sh/jobs.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 2fd7aaa..ebf5ed8 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); |