Re: wait on non-child

From: Carlos Eduardo <carana2099_at_gmail.com>
Date: Mon, 31 Aug 2026 13:51:43 -0300

Em seg., 31 de ago. de 2026 às 13:14, Saj Goonatilleke via skaware <
skaware_at_list.skarnet.org> escreveu:

> This is kind of interesting because it looks like execline wait accepts
> the order to wait on a non-child (is this valid?), but nevertheless
> proceeds when some other child exits -- not one given in the pids block.
> Behaviour is the same if we substitute '1' with some random nonexistent
> pid. POSIX is boring in that waitpid(2) gives ECHILD in this case.


Execline's wait doesn't use waitpid like that, since that function doesn't
support waiting for more than one process at once (and the command accepts
a list of PIDs). AIUI, unless it checks ahead of time whether the PID(s)
exist(s), it can't tell whether the PIDs given in its command line are
valid children or not, so it blindly reaps children until the criteria
specified on its command line are satisfied.


> There are perhaps valid (if crazy) use cases for wait-on-init. PID 1
> should always exist, so I wished we could 'wait -t ... 1' to get a sleep(1)
> with Bernstein-chaining. ;)


s6-sleep from s6-portable-utils [1] is exactly what you're looking for;
after the sleep interval it accepts a command line to exec into:

https://skarnet.org/software/s6-portable-utils/s6-sleep.html

I don't think there is anything wait-on-init could do that s6-sleep (or
foreground { sleep }) can't.
Received on Mon Aug 31 2026 - 18:51:43 CEST

This archive was generated by hypermail 2.4.0 : Mon Aug 31 2026 - 18:52:33 CEST