HomeFreeBSD

timeout(1): Document the reaper implementation and behaivor

Description

timeout(1): Document the reaper implementation and behaivor

If timeout(1) runs with the --foreground option, it becomes the reaper
of the command and its descendants and will wait for all of them to
terminate. This behavior is different from the old FreeBSD version and
GNU version.

For example, if there is a descendant running in the background, like:
$ timeout -s INT 2 sh -c 'sleep 4 & sleep 5'
when timeout(1) sends the SIGINT to all descendants, the child 'sh'
process and the foreground 'sleep 5' process will immediately terminate,
but the background 'sleep 4' will be reparented to the timeout(1)
itself. Because a background process ignores SIGINT and SIGQUIT,
the whole command completes until the background 'sleep 4' finishes.

In comparison, the old FreeBSD version and GNU version will just
terminate itself, letting the background 'sleep 4' process be reparented
to an upper reaper like init.

The POSIX.1-2024 standard doesn't specify the required behavior in such
cases, so I decided to keep the current implementation. Nonetheless,
the updated timeout(1) has changed a lot in order to conform to the
standard.

Obtained-from: DragonFly BSD

Details

Provenance
aly_aaronly.meAuthored on Apr 3 2025, 2:54 AM
baptCommitted on Apr 16 2025, 7:45 PM
Parents
rGa25b03791764: timeout(1): adapt the preserve_status test to the new behaviour
Branches
Unknown
Tags
Unknown