execline
Software
skarnet.org
The wait program
wait waits for a set of children, then executes a program.
Interface
In an execlineb script:
wait [ -a | -o ] [ -u ] [ -t timeout ] { [ pids... ] } prog...
- wait reads a list of pids in a
(possibly empty) block,
and unquotes it.
- wait waits for every child whose pid is
listed in pids.... If pids... is an
empty list, it waits for every child process it has.
- wait then execs into prog....
Options
- -t timeout : wait for a maximum
of timeout milliseconds. If there still are living processes
among pids... (or among wait's children if
pids... is an empty list), after timeout
milliseconds, they will not be waited for. In particular, -t0
tells wait to perform a single reaping pass on current zombies
and immediately exec into prog....
- -o : wait for one of the listed
pids — exec into prog as soon as one of the
listed children dies. (If no pid is listed, wait for one child to die.)
- -a : wait for all of the listed pids.
This is the default.
- -u : do not export the result in the environment,
even if wait succeeds.
Environment variables
If the -u option has been given, wait execs into prog...
with the ! and ? environment variables unset. Same thing if an
error occurred before wait could successfully reap a zombie.
Otherwise, the ! environment variable is set to the pid of a reapt zombie,
and the ? environment variable is set to its exit code. Here is how wait
decides what pid to report:
- If the -o option has been given, ! is set to the pid of the
one zombie that has just been reapt.
- Otherwise, if wait has been given an empty list of pids (meaning it should
wait for all of its children), then ! is set to the pid of the last child it has
waited for. If there were no children, ! and ? are unset.
- Otherwise, ! is set to the last pid in the list provided to wait.
Notes
- For POSIX
compatibility, wait also works when it cannot find a block.
In that case, all the options are still supported and have the same
effect, but the rest of the command line is interpreted as pids...
arguments and wait does not execute into a program; instead, it exits
with a conforming exit code.