#22721: fix(exec): keep child runs attached on macOS for reliable output
size: XS
Cluster:
Node and macOS Enhancements
## Summary
Fixes #22350.
On macOS LaunchAgent sessions, spawning exec child processes with `detached: true` can cause stdout/stderr pipes to behave like fire-and-forget runs (command exits quickly with no captured output). This made `exec` appear to return `(no output)` even for simple commands.
This change:
- disables detached mode on **darwin** (same as existing win32 behavior)
- keeps detached mode enabled on Linux/other POSIX
- adds a focused unit test for platform policy (`shouldUseDetached`)
## Validation
- `corepack pnpm -s vitest run src/process/supervisor/adapters/child.test.ts` ✅
## Risk
Low. Scope is limited to process spawn options in child adapter. Linux behavior remains unchanged.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Disables detached process spawning on macOS to fix stdout/stderr pipe capture issues in LaunchAgent sessions. The PR extracts the platform-specific detached-mode logic into a testable `shouldUseDetached()` function that returns false for both `win32` and `darwin`, while keeping Linux/POSIX behavior unchanged (detached=true with fallback). The fix mirrors the existing Windows Scheduled Task compatibility pattern and includes focused unit test coverage.
<h3>Confidence Score: 5/5</h3>
- Safe to merge - targeted fix with clear test coverage and no breaking changes to existing platforms
- The change is minimal, well-scoped, and directly addresses a documented macOS issue. The new `shouldUseDetached()` helper improves testability, tests cover all three platform cases, and Linux behavior remains unchanged. The fallback mechanism is already in place via `spawnWithFallback()`
- No files require special attention
<sub>Last reviewed commit: 4c67157</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#17862: fix: Windows exec returns empty output when pty=false
by MisterGuy420 · 2026-02-16
83.7%
#8038: fix(exec): use spawnWithFallback to handle EBADF on macOS
by FelixFoster · 2026-02-03
77.4%
#19063: CI/macOS: disable Vitest vmForks for TS tests to stop mock-state le...
by agisilaos · 2026-02-17
73.8%
#9250: Fix: Add shell:true for Windows .cmd files to prevent spawn EINVAL ...
by vishaltandale00 · 2026-02-05
73.4%
#15619: fix: clean up orphan LaunchAgent plist on bootstrap failure
by superlowburn · 2026-02-13
73.1%
#6577: fix: add null checks for stdout/stderr when using inherit-stdio fal...
by ncmalan · 2026-02-01
72.9%
#17929: fix(skills): augment PATH with /etc/paths on macOS for binary detec...
by lailoo · 2026-02-16
72.3%
#4709: fix(daemon): include user bin dirs in macOS LaunchAgent PATH
by ekson73 · 2026-01-30
72.3%
#18126: Fix process tree kill leaving orphans on Unix (manual traversal fal...
by Clawborn · 2026-02-16
72.1%
#5168: Fix: force UTF-8 for Windows exec
by ManojINaik · 2026-01-31
72.1%