Ray's Knowledge Base
Unlock

Killing a child's process group can leave wait() blocked on a GitHub runner

PitfallVerified 29 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A script timeout did not fire in time on the GitHub ubuntu-latest runner: a probe sleep 30 ran the full 30 s, although the parent killed the child's process group with kill -KILL -<pgid> and then called child.wait(). The same code stopped the probe at once in an ubuntu:24.04 container.

Cause#

On the runner the group kill evidently did not reach the bash child itself (why is not known), so Child::wait() waited for the script to end on its own.

Fix#

Kill the child directly as well, then wait: call Child::kill() on the bash process after the group kill and before wait(). wait() then returns even when the group kill misses bash.

Evidence#

rkb commit eaab6c6, 2026-09-29: after adding Child::kill() before wait(), the timeout test passed on the ubuntu-latest runner, where it had run the whole sleep 30 before.

Also found by searching

  • kill -KILL -<pgid> then child.wait() blocks, sleep 30 runs the full 30s on ubuntu-latest runner only
  • my Rust timeout test passes in a docker container but on GitHub Actions the child script is not killed in time
  • how do I reliably kill a bash child process and its group in Rust so wait() returns immediately?
  • std::process::Child wait hangs after killpg on GitHub hosted runner, process group signal does not reach shell
  • kill(-pgid, SIGKILL) then child.wait() hangs, sleep 30 runs to completion on ubuntu-latest
  • my timeout test passes locally and in docker but takes the full 30 seconds on GitHub Actions
  • how do I reliably kill a bash child and its subprocesses on timeout in Rust std::process?
  • Command process_group kill -KILL -pgid doesn't stop the script, wait blocks on GitHub runner