Avoid signaling recycled process groups
Merged
AU
3mo ago+96+96+01234567890123456789-33-33-01234567890123456789
After the direct child has been reaped, stop trusting its cached numeric process-group id because the kernel may reuse it. Teardown now signals only a foreground group freshly observed through the retained PTY. Includes regression coverage for an unrelated cached group and for reaping a distinct foreground job after the leader has genuinely exited.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Prevents teardown from signaling a recycled process group after the child is reaped. Now we only stop the foreground group read from the retained PTY, avoiding signals to unrelated jobs.
- Bug Fixes
- Stop trusting cached
process_group_idonce the child is reaped; use freshforeground_process_group_idfrom the PTY. - Switch to
killProcessGroupWithTimeoutsto target only the active foreground group. - Add regression tests for ignoring stale groups and for killing a distinct foreground job after the leader exits.
- Stop trusting cached
Summary by CodeRabbit
- Bug Fixes
- Improved subprocess cleanup after a process exits.
- Prevented teardown from targeting stale process information, reducing the risk of terminating unrelated foreground processes.
- Ensured remaining subprocesses are consistently cleaned up when their leader exits.