Repository navigation
fix(tools): stop cmd.exe when a Windows PTY Bash call is cancelled - #486
Merged
Merged
Conversation
…n CI Both foreground Bash tools fall back to `cmd /C` on Windows, and no CI job ran Rust tests there. A new windows-latest job runs foreground_windows.rs: a loop only cmd.exe keeps going is cancelled, timed out and left to finish, through each tool. A cancelled call must stop its cmd.exe the way a timed-out call already does. Refs #373
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The PTY Bash tool, the default Bash tool on Windows, falls back to `cmd /C` there without kill_on_drop, so dropping a cancelled call left cmd.exe running. BashTool's fallback already set it, and both kill cmd.exe on timeout. Children of cmd.exe still outlive a cancel or a timeout until #373's tree-cleanup decision. Refs #373
The PowerShell tool is a foreground shell too, and it spawns powershell without kill_on_drop. Its loop runs inside powershell.exe itself, so the file stops growing once that process is gone. The Windows job's limit drops to 20 minutes; a cold build took about 2. Refs #373
The timeout cases need one tick before the call times out. At 2.5 s a cold powershell.exe on a busy runner, beside seven other tests, could miss it; 6 s leaves room. Refs #373
This was referenced Nov 16, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cmd.exeit started. Itscmd /Cfallback lackedkill_on_drop, so a dropped call leftcmd.exerunning. The plain Bash tool's fallback already set it, and both already killcmd.exeon timeout.powershell(orpwsh) running to finish the command, for example aRemove-Itemafter aStart-Sleep. It now stops with the call.foreground_windows.rsagainst all three shells, and both fixes failed first there, as shown below.Context
crates/tools/src/pty_bash.rsandcrates/tools/src/powershell.rs: onekill_on_drop(true)each, with a comment;crates/tools/tests/foreground_windows.rs;windows-latestjob in.github/workflows/rust-ci.yml.cmd.exeorpowershellstill outlive a cancel or timeout. That needs the Job Object or process-group decision recorded in Complete foreground shell descendant cancellation and Windows cleanup #373; this test file is where its failing case would go.Changes
run_windows_fallback(PTY Bash) and the PowerShell tool spawn their shell withkill_on_drop(true), likeBashTool::execute_windows.foreground_windows.rs(#![cfg(windows)]) runs a loop that only the shell itself keeps going, appending a line to a file:cmd.exeruns a builtinfor /L, waiting inping;powershellruns aforloop withAdd-Content, waiting inStart-Sleep.Validation
f5c5b379(tests only): 5 passed andcancelled_pty_fallback_stops_its_cmdfailed. Three seconds after the cancel, the tick count had gone from 4 to 7.926e9ddd(PowerShell tests, before that fix): 7 passed andcancelled_powershell_stops_its_processfailed, with 5 ticks, then 8.c0671480(the PTY fix): 6 of 6 passed.1357470): 15 of 15 checks passed. In Rust CI run 43611746750, the Windows job passed all 8 tests inforeground_windows.rs. It passed 8 of 8 ona651089too, in run 43610074288.a651089(the last commit only lengthens a Windows-only test timeout), fromsrc-rust/:cargo fmt --all -- --checkclean;cargo clippy --workspace --all-targets --locked -- -D warningsclean on 1.100.0 and 1.99.1;cargo clippy --package claurst-tools --all-targets --features computer-use --locked -- -D warningsclean;cargo test --workspace --locked --no-fail-fast(scratchHOME): 3253 passed, 0 failed, 66 ignored.actionlint .github/workflows/rust-ci.yml: clean.git diff --check: clean.An independent review checked the cmd quoting, the redirect,
pingwith null stdin, reads that collide with the shell's writes, and the timing. It found the PowerShell gap and a tight timeout on a coldpowershell.exestart; both are fixed. It found nothing above a nit at the final head.Known limits and follow-ups
post_create_command(crates/tools/src/worktree.rs,cmd /C … .output()) has nokill_on_dropand no timeout.crates/tools/src/formatter.rs) leaves a hung formatter running, on every OS.cmd /Cfallbacks pass the command through Rust's Windows argument quoting. That writes an inner"as\", whichcmd.exedoes not unescape, so a command such asgit commit -m "fix bug"arrives mangled. The test uses no quotes.ToolContextbreaks it only here. Making the job a required check would catch that.PR Readiness