Repository navigation
fix(core): kill a command's escaped descendants at teardown - #511
Conversation
GNU timeout and setsid move processes out of the command's group, so killing the group left them running under PID 1. Teardown now freezes the group, follows parent PIDs to every descendant until a scan finds nothing new, kills them all, and confirms each one exited. Commands also get PWD set to their working directory and no inherited OLDPWD.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 624f8969fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a36851ee9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… during teardown Teardown no longer sends SIGSTOP to the whole group, which froze the watcher that kills the tree if QQ dies mid-collection. It stops each member individually and skips the watcher. On macOS, a stopped PID is resumed and dropped unless a fresh snapshot still shows it in the command's tree, so a recycled PID is never killed. The PWD test now runs a program that reads the environment directly, with a known stale PWD and OLDPWD, and test process probes no longer block the runtime.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Change
On Unix, a command whose descendants leave its process group (GNU
timeout,setsid) kept running after cancel, timeout, or the end of the run, reparented to PID 1.timeout 300 cargo test 2>&1 | tailwas the common case.QQ still launches commands without a helper process. Now, at teardown, it stops the group, then walks parent PIDs from it:
/proc/<pid>/staton Linux,ps -A -o pid=,ppid=,pgid=on macOS. It stops each descendant it finds and rescans until a scan finds nothing new, for at most 64 rounds. Then it kills every descendant and the group. Confirmation waits for every collected PID (pidfds on Linux), not only the group. The walk runs inspawn_blocking.shellandexecalso setPWDto the command's working directory and drop the inheritedOLDPWD.Verification
cancel_and_timeout_kill_descendants_that_left_the_group,a_yielded_escaped_tree_dies_when_the_run_ends, andcommands_see_their_working_directory_in_pwd_and_no_oldpwdfail on origin/main: the marked PIDs are still alive after teardown, andOLDPWDis inherited. All three pass with this change. Each test finds its processes withpsby a uniquesleepargv marker and polls with a bound; no fixed sleeps.cargo nextest run -p qq-core -E 'test(/shell|process|teardown|yield/)': 92/92 on Linux.cargo xtask check: passed locally. The full CI gate passed on5a36851e.run in place (macos-latest)runs the three new tests with Homebrew GNUtimeoutand util-linuxsetsid, and passes: https://github.com/retsu-AI/qq/actions/runs/41016563967Known impact
Not cleaned up:
setsidjob from a command that already finished.On macOS, PIDs are tracked by number, not pidfd, so a PID reused during the bounded confirmation window could be misread as still alive. That would report the cleanup as unobserved; it never kills an unrelated process.
docs/guide/permissions.mdstates these limits.sessions::tests::approvals::goal_parent_deadline_preserves_a_sponsored_childs_unanswered_approvalfailed on its first try in two CI gate runs on this branch and passed on retry, which nextest flags as flaky. It runs no shell command. It passed 150/150 locally under concurrent load, and the final run passed after a rerun of the failed job. I have not found a link to this change.