Skip to content

fix: kill the Windows cmd.exe shim process tree - #344

Merged
SebTardif merged 1 commit into
mainfrom
fix/windows-cmd-process-tree
Dec 3, 2026
Merged

SebTardif merged 1 commit into
mainfrom
fix/windows-cmd-process-tree

Conversation

@SebTardif

Copy link
Copy Markdown
Contributor

Summary

Stop Windows patchloom.cmd launches by killing the process tree. child.kill() only stops cmd.exe, so the real CLI could keep running after Verify MCP or a timed-out command.

Why

patchloomLaunch runs .cmd and .bat shims as cmd.exe /d /s /c. Node's kill and execFile timeout do not kill that grandchild. Verify MCP kills its child when the probe finishes, including on success.

taskkill /T /F stops the tree. A non-zero taskkill exit, or a missing taskkill.exe, falls back to child.kill(). A direct patchloom.exe still uses child.kill().

Verification

  • npm run check passed: 470 tests, coverage, and vsce package.
  • On this machine, killPatchloomChild stopped ping.exe started under cmd.exe /c.
  • Reviewer bug before commit: a failed taskkill did not fall back to child.kill(). That fallback is in this commit, with a unit test.

Checklist

  • All commits in this pull request are signed off with git commit -s
  • I ran npm run check and it passes
  • I updated docs if user-facing behavior changed
  • I am contributing this work under the repository license (MIT)

child.kill() and execFile's timeout stop only cmd.exe. A patchloom.cmd
launch therefore leaves the real CLI running after Verify MCP finishes
or a command times out.

Kill those shims with taskkill /T /F. If taskkill is missing or exits
non-zero, fall back to child.kill(). Direct patchloom.exe launches
still use child.kill(). A Windows test starts ping under cmd.exe /c
and checks the grandchild is gone.

npm run check passed (470 tests).

Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
Comment thread src/binary/launch.ts
Comment on lines +99 to +114
const child = execFile(launch.file, launch.args, {
...execOptions,
encoding: "utf8",
shell: launch.shell,
windowsVerbatimArguments: launch.windowsVerbatimArguments
}, (error, stdout, stderr) => {
disarm();
if (error) {
reject(error);
return;
}
resolve({
stdout: typeof stdout === "string" ? stdout : "",
stderr: typeof stderr === "string" ? stderr : ""
});
});
@SebTardif
SebTardif marked this pull request as ready for review December 3, 2026 14:49
@SebTardif
SebTardif merged commit 06bf562 into main Dec 3, 2026
23 checks passed
@SebTardif
SebTardif deleted the fix/windows-cmd-process-tree branch December 3, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants