HomeFreeBSD

timeout(1): Fix the handling of repeated terminating signals

Description

timeout(1): Fix the handling of repeated terminating signals

This actually fixes the following two issues:

  • If a terminating signal (e.g., HUP/INT/TERM) was received, timeout would propagate it to the command and then ignore it. So it was unable to resend the same terminating signal to the command. This was different from the GNU's timeout(1), and also contradicted the POSIX.1-2024 standard.
  • Sending two different terminating signals would break timeout(1)'s --kill-after mechanism. That was because the second signal would break the for() loop, so the second SIGALRM set by '--kill-after' would never be caught.

    For example, in one shell run: $ time timeout -f -v -s INT -k 1 2 sh -T -c \ 'trap date INT HUP; sleep 5; echo ok; date' and in another shell run: $ pkill -INT timeout; pkill -HUP timeout in the end, the time(1) would report it cost 5 seconds instead of the expected 3 seconds.

Obtained-from: DragonFly BSD

Details

Provenance
aly_aaronly.meAuthored on Apr 2 2025, 4:14 PM
baptCommitted on Apr 16 2025, 7:45 PM
Parents
rG06c74693c286: timeout(1): Also send SIGCONT because the child may be stopped
Branches
Unknown
Tags
Unknown