The procps-ng kill binary (version 4.0.4+) has an argument parsing issue
where negative PIDs like "-12345" are misinterpreted as options because
they start with a dash. This causes the binary to fall back to "-1" which
means "all processes", resulting in kill(-1, signal) being called.
This was discovered through an extensive murder investigation after 26
Claude AI instances were killed when running TestCleanupOrphanedSessions.
Each investigator left notes for their successor, eventually leading to
the discovery that:
- exec.Command("bash", "-c", "kill -KILL -PGID") is SAFE (uses bash builtin)
- exec.Command("kill", "-KILL", "-PGID") is FATAL (uses /usr/bin/kill)
Verified via strace:
/usr/bin/kill -KILL -12345 → kill(-1, SIGKILL) # WRONG!
/usr/bin/kill -KILL -- -12345 → kill(-12345, SIGKILL) # Correct!
The fix adds "--" before negative PGID arguments to explicitly end option
parsing, ensuring the negative number is treated as a PID/PGID argument.
Full investigation: https://github.com/groblegark/gastown/blob/main/MURDER_INVESTIGATION.md
Co-authored-by: Refinery <matthew.baker@pihealth.ai>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>