codex-companion cancel taskkill fallback breaks under Git Bash — MSYS translates /PID arg to C:/Program Files/Git/PID
Environment
- codex plugin v1.0.4
- Windows 10 Pro 10.0.19045
- Git Bash (MSYS2) — the default Bash environment for Claude Code on Windows
node codex-companion.mjs cancel <job-id>invoked when a job has stalled
Symptom
When codex-companion's soft-cancel IPC fails and the script falls back to taskkill /PID <pid> /T /F, Git Bash's MSYS layer translates the literal /PID argument into a Windows path, mangling the command:
taskkill /PID 34428 /T /F: exit=1: ERROR: Invalid argument/option - 'C:/Program Files/Git/PID'.
Type "TASKKILL /?" for usage.
MSYS sees /PID as a root-level Unix path and prefixes it with the Git for Windows install root. The actual taskkill receives C:/Program Files/Git/PID 34428 /T /F and rejects the bogus argument.
Result: the cancel fallback fails, the wedged codex process keeps running, and the user has to clean up manually via Stop-Process -Id <pid> -Force from PowerShell.
Reproduction
- Launch any codex adversarial-review job from Git Bash on Windows
- Trigger a stall condition (e.g., the IPC deadlock described in #330; or kill the codex process out-of-band so the broker thinks it's running but it isn't)
- Run
node codex-companion.mjs cancel <job-id>from Git Bash - Observe the MSYS-mangled taskkill stderr
Suggested fixes (any of these works)
- Set
MSYS_NO_PATHCONV=1in the env for the taskkill invocation - Pass
//PID(double-slash escape recognized by MSYS as "no translation") - Preferred: on Windows, use
powershell.exe -NoProfile -Command "Stop-Process -Id <pid> -Force"instead oftaskkill— no MSYS translation, cleaner exit semantics, no dependency on which shell wraps the node invocation
Option 3 is what we recommend to our users in our orchestrator's recovery guidance, so confirmed working.
Reference
Same orchestrator run as the IPC deadlock issue (#330). Job ID review-mpbtwgbj-gswbux, PID 34428.
Confirming this on a second environment and adding the exact code location + a tested minimal patch.
Repro env: Windows 11 (26200), codex plugin v1.0.4, launched from Claude Code — whose default SHELL is /bin/bash.exe (Git Bash). So this isn't an exotic config: any Windows user on the Claude Code default shell hits it.
Root cause (one line). terminateProcessTree shells out for the kill, and runCommand spawns through process.env.SHELL on Windows:
plugins/codex/scripts/lib/process.mjs
// runCommand
shell: process.platform === "win32" ? (process.env.SHELL || true) : false,
...
// terminateProcessTree (win32 branch)
runCommandImpl("taskkill", ["/PID", String(pid), "/T", "/F"], {
cwd: options.cwd,
env: options.env
});
Because the spawn goes through Git Bash, MSYS path conversion rewrites the first /-flag: /PID → C:/Program Files/Git/PID, so taskkill aborts with ERROR: Invalid argument/option - 'C:/Program Files/Git/PID'.
Scope is broader than the cancel fallback. Since it's in terminateProcessTree, it also fires from the SessionEnd lifecycle hook (teardownBrokerSession) and broker teardown — every process-tree kill fails, leaving orphaned node processes and surfacing as repeated "Background shell failed" noise, not just on /codex:cancel.
Verified minimal fix — disable MSYS conversion for only this spawn, so the existing taskkill path (and its "process not found" handling) is otherwise untouched:
runCommandImpl("taskkill", ["/PID", String(pid), "/T", "/F"], {
cwd: options.cwd,
env: { ...(options.env ?? process.env), MSYS_NO_PATHCONV: "1", MSYS2_ARG_CONV_EXCL: "*" }
});
Proof the flags survive once conversion is off:
$ taskkill /PID 999999 /T /F
ERROR: Invalid argument/option - 'C:/Program Files/Git/PID'. # broken
$ MSYS_NO_PATHCONV=1 taskkill /PID 999999 /T /F
ERROR: The process "999999" not found. # flags intact (and this
# "not found" case is already
# handled gracefully)
The powershell.exe Stop-Process approach in the original report also works; the env-scoped patch above is just the smallest diff and keeps the current taskkill output parsing. Happy to open a PR if useful.
Duplicate of #525.