From 60eca880ee450f822fc32cf5bd9c32ab04b6956a Mon Sep 17 00:00:00 2001
From: Laurent Bercot
Date: Mon, 12 Oct 2026 00:58:40 +0000
Subject: Add dollarsharp, rewrite wait
Entirely untested, will test now
---
doc/wait.html | 49 +++++++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 18 deletions(-)
(limited to 'doc/wait.html')
diff --git a/doc/wait.html b/doc/wait.html
index 44197a0..d38b06a 100644
--- a/doc/wait.html
+++ b/doc/wait.html
@@ -30,7 +30,7 @@
- wait [ -I | -i ] [ -a | -o ] [ -r | -t timeout ] { [ pids... ] } prog...
+ wait [ -a | -o ] [ -u ] [ -t timeout ] { [ pids... ] } prog...
@@ -40,36 +40,49 @@ 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....
+ - wait then execs into prog....
Options
- - -r : equivalent to -t 0. Do not
-pause: only reap processes that are already dead when wait
-is invoked.
- -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 reaped.
- - -I : loose. If wait times out while
-waiting for children to die, it will still
-exec into prog.... This is the default.
- - -i : strict. If wait times out, it
-will print an error message and exit 99.
+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.)
-The ! environment variable will be set to the
-pid that died, and the ? environment variable will contain an
-approximation of its exit code. If no
-listed child has died before wait has to exec (either because
-it timed out or it has no suitable children left), the ? and
-! environment variables are unset.
- -a : wait for all of the listed pids.
-Do not touch the ! or ? variables. This is the default.
+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
--
cgit v1.3.1