summaryrefslogtreecommitdiffstats
path: root/bin/sh/sh.1
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-06-29 22:37:45 +0000
committerjilles <jilles@FreeBSD.org>2010-06-29 22:37:45 +0000
commit8fcbe1caf89944ec27f00e1265b29374fd3e05de (patch)
treefec6cbce2d09b1054b1fc671f8093cc73e9c8694 /bin/sh/sh.1
parent49f38732fcf51babc8f4ba652aa99ac2a78eeb4b (diff)
downloadFreeBSD-src-8fcbe1caf89944ec27f00e1265b29374fd3e05de.zip
FreeBSD-src-8fcbe1caf89944ec27f00e1265b29374fd3e05de.tar.gz
sh: Forget about terminated background processes sooner.
Unless $! has been referenced for a particular job or $! still contains that job's pid, forget about it after it has terminated. If $! has been referenced, remember the job until the wait builtin has reported its completion (either with the pid as parameter or without parameters). In interactive mode, jobs are forgotten after termination has been reported, which happens before primary prompts and through the jobs builtin. Even then, though, remember a job if $! has been referenced. This is similar to what is suggested by POSIX and should fix most memory leaks (which also tend to cause sh to use more CPU time) with long running scripts that start background jobs. Caveats: * Repeatedly referencing $! without ever doing 'wait', like while :; do foo & echo started foo: $!; sleep 60; done will still use a lot of memory and CPU time in the long run. * The jobs and jobid builtins do not cause a job to be remembered for longer like expanding $! does. PR: bin/55346
Diffstat (limited to 'bin/sh/sh.1')
-rw-r--r--bin/sh/sh.16
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index aed995f..1498564 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -32,7 +32,7 @@
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\" $FreeBSD$
.\"
-.Dd May 24, 2010
+.Dd June 29, 2010
.Dt SH 1
.Os
.Sh NAME
@@ -1106,6 +1106,10 @@ command executed from the current shell.
For a
pipeline, the process ID is that of the last command in the
pipeline.
+If this parameter is referenced, the shell will remember
+the process ID and its exit status until the
+.Ic wait
+built-in command reports completion of the process.
.It Li $0
(zero) Expands to the name of the shell or shell script.
.El
OpenPOWER on IntegriCloud