Reap foreground job-control process groups
Merged
AU
4mo ago+273+273+012345678901234567890123456789-51-51-01234567890123456789
Summary
- capture the PTY foreground process-group id before subprocess teardown
- signal and probe the session-leader and distinct foreground groups under one shared deadline
- add a regression with a SIGHUP-resistant foreground job group
Verification
- red regression on babe4266c: foreground group remained alive
- green on 47e9bd4c9:
zig build test -Dtest-filter="subprocess stop" - universal ReleaseFast GhosttyKit archive validated and published
cmux issue: https://github.com/manaflow-ai/cmux/issues/9573
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Reap foreground job-control process groups when stopping a subprocess so foreground jobs don’t linger after the terminal closes. Fixes SIGHUP-resistant foreground groups remaining alive (see cmux issue #9573).
- Bug Fixes
- Capture the PTY’s foreground process-group id before teardown.
- Send SIGHUP then SIGKILL to both the primary and distinct foreground groups under a shared deadline.
- Handle direct-child reaping and transient missing-group windows; ignore expected
EPERMfromkillpgon Darwin. - Add a regression test that kills a SIGHUP-resistant foreground group.
Summary by CodeRabbit
- Bug Fixes
- Improved terminal process shutdown to reliably terminate child processes and their descendants.
- Added handling for processes running in separate foreground terminal groups.
- Made shutdown more resilient when processes exit or temporarily become unavailable.
- Improved reporting of process groups involved during terminal cleanup.