#17862: fix: Windows exec returns empty output when pty=false
size: XS
trusted-contributor
Cluster:
Node and macOS Enhancements
## Summary
On Windows, the exec tool returns empty output when pty=false (the default) when running via Scheduled Task. This is a regression introduced in the process supervisor refactoring (commit cd44a0d01).
The root cause is that the new child adapter always uses detached: true, but on Windows, detached processes don't have proper console handles for stdout/stderr capture.
## Changes
- Changed detached: true to detached: process.platform !== "win32" in src/process/supervisor/adapters/child.ts
- This restores the previous behavior where Windows used detached: false
## Testing
- All existing tests pass (20 supervisor tests, 5 exec tests, 3 bash-tools.exec tests)
Fixes openclaw/openclaw#17806
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes a Windows-specific regression where exec tool returns empty output when `pty=false`. The root cause was that `detached: true` (introduced in the supervisor refactoring at commit cd44a0d01) causes Windows child processes to lose their console handles, preventing stdout/stderr capture — especially when running via Scheduled Task.
- Sets `detached: process.platform !== "win32"` so Windows uses `detached: false` while Unix/macOS retains `detached: true` (needed for process-group kill via `process.kill(-pid)`)
- Conditionally removes the "no-detach" spawn fallback on Windows since it would be redundant when already non-detached
- Process cleanup is unaffected: Windows `killProcessTree` uses `taskkill /T /PID` which works regardless of detach mode
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it is a focused, well-understood platform fix with no side effects on non-Windows platforms.
- The change is minimal (one file, two small hunks), addresses a clear regression with a well-documented root cause, and preserves existing behavior on Unix/macOS. The fallback guard is logically correct — no redundant fallback when already non-detached. Process cleanup paths on both platforms are unaffected. Existing tests pass because CI runs on Linux where `detached` remains `true`.
- No files require special attention.
<sub>Last reviewed commit: 5a93871</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22721: fix(exec): keep child runs attached on macOS for reliable output
by rylena · 2026-02-21
83.7%
#19495: fix: handle Chrome process re-parenting on Windows
by andenwick · 2026-02-17
78.0%
#5496: Fix: Windows path separators stripped in Gateway scheduled task
by giuliozelante · 2026-01-31
76.4%
#18126: Fix process tree kill leaving orphans on Unix (manual traversal fal...
by Clawborn · 2026-02-16
75.6%
#5168: Fix: force UTF-8 for Windows exec
by ManojINaik · 2026-01-31
75.2%
#19504: fix(gateway): avoid stale running status from Windows Scheduled Task
by Fologan · 2026-02-17
74.9%
#9250: Fix: Add shell:true for Windows .cmd files to prevent spawn EINVAL ...
by vishaltandale00 · 2026-02-05
74.4%
#10708: fix: handle Windows PATH case-sensitivity in exec environment
by Yida-Dev · 2026-02-06
73.6%
#11362: fix: name parent shim processes for clarity in ps output
by anooprdawar · 2026-02-07
73.4%
#10714: fix: handle Windows PATH case-sensitivity in node register invoke
by Yida-Dev · 2026-02-06
73.3%