Skip to content

timeout: -k sends KILL even though the first signal already ended the command #16642

Open

Description

@sylvestre

timeout -k sends KILL right after the first signal, even when that signal already ended the command.

$ timeout --verbose -k 2 -s INT 0.2 sleep 5; echo $?

uutils:

timeout: sending signal INT to command 'sleep'
timeout: sending signal KILL to command 'sleep'
137

GNU 9.12:

timeout: sending signal INT to command 'sleep'
124

The KILL also goes out immediately instead of after the 2s grace period.

GNU test: bash util/build-gnu.sh && bash util/run-gnu-test.sh tests/env/env-signal-handler.sh

Part of #14705

Activity

  1. Sahil-Gulihar commented on Nov 17, 2026

    @Sahil-Gulihar

    Hi, I'd like to work on this. The plan is to only send the KILL after the -k duration if the command is still running after the first signal, and to add a test for the -s INT 0.2 sleep 5 case (expected exit 124, no KILL message). Could I be assigned?

  2. pjt222 commented on Nov 19, 2026

    @pjt222

    The same repro across signals, in case it helps with the test cases. This is on Ubuntu 26.04.1 (the ubuntu:26.04 image), with uutils timeout 0.10.0 (the image's) and the 0.12.0 release binary (coreutils-0.12.0-x86_64-unknown-linux-musl) against GNU timeout 9.7, which the image also ships as gnutimeout. The image's sleep is uutils's, so the child is GNU sleep, shipped there as gnusleep, and only timeout differs. The command is timeout --verbose -k 2 -s SIG 0.2 gnusleep 5. Each cell held in three runs out of three, for 0.10.0 and 0.12.0 alike:

    -s uutils 0.10.0 and 0.12.0 GNU 9.7
    HUP, INT, QUIT, USR1, USR2, ALRM, PIPE KILL sent right after the signal, exit 137 at about 0.21 s no KILL, exit 124 at about 0.21 s
    TERM no KILL, exit 124 at about 0.21 s no KILL, exit 124 at about 0.21 s
    WINCH, URG, CONT, CHLD (their default action does not end sleep) KILL after the 2 s grace, exit 137 at about 2.21 s the same

    So the early KILL happens for every signal tried that ends the command, except TERM. When the first signal does not end the command, the grace period is honoured as in GNU.

  3. added a commit that references this issue on Nov 22, 2026
    da393b2
  4. added a commit that references this issue on Nov 23, 2026
    245e3cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions