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

Aaron LI aly at crater.dragonflybsd.org
Tue Mar 18 19:35:54 PDT 2025


commit f01f4f52966a300cb600b7cddc8627c4d14154f2
Author: Aaron LI <aly at aaronly.me>
Date:   Tue Mar 4 13:09:45 2025 +0800

    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.

Summary of changes:
 usr.bin/timeout/timeout.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/f01f4f52966a300cb600b7cddc8627c4d14154f2


-- 
DragonFly BSD source repository


More information about the Commits mailing list