Repository navigation
fix(core): start the command watcher before the command so group signals cannot kill it - #498
Conversation
…als cannot kill it
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: 3ba555e5eb
ℹ️ 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: 698237ba45
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9ca5f0987
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
Fixes the Linux main-CI flake in
tools::shell::orphan_tests::a_killed_server_takes_its_commands_with_it(main run 40810178056).What was broken for users: on Unix, each shell command's process group has a watcher that kills the group if QQ dies (SIGKILL included). The watcher was spawned after the command and joined its group. A command that signals its own group right away (
kill -s TERM 0, common in scripts) could kill the watcher beforetrap '' … TERMran. The command then outlived QQ.Fix: the watcher now starts first, leading its own group. It sets its traps, writes one byte on stdout to say it is ready, and only then is the command spawned into the watcher's group. The guard and
goal_checknow use the watcher's group id instead of assuming the group id is the command's pid.Verification
New
tools::shell::watcher_tests::the_watcher_ignores_group_signals_before_a_command_joinsreads the watcher'sSigIgnmask from/procwhen the watcher is handed over.Orphan test under stress, 3000 iterations at 64 threads: 3 to 9 failures before the fix, 3000/3000 passing after.
With a busy loop before the watcher's trap, the old code failed 3 of 5 runs; with the fix, the same delay passes 20/20.
cargo xtask checkpassed.tools::tests::a_command_starts_in_a_group_its_ready_watcher_leadsruns a command through the shell tool and checks that it joined a group led by a watcher that already ignores TERM. It fails on the old code (the command leads its own group) and passes with the fix.Because a command no longer leads its group, it can
setsid()without forking and leave it. Stopping a command now also kills it directly on Linux (macOS already did).a_command_that_leaves_its_group_still_stops_on_timeouthung before this and passes now.Startup checks cancellation again after the watcher is ready, so a cancel during watcher startup never launches the command.
Independent of #497 (Windows clippy fix); both are needed for main CI to be green.