#8038: fix(exec): use spawnWithFallback to handle EBADF on macOS
size: S
Cluster:
Windows Path and Exec Fixes
Fixes #8021.
## The Problem
On macOS with Node.js 22+, throws when trying to inherit stdin in a background/daemon context. The existing has logic to handle this, but was bypassing it by calling directly.
## The Fix
Updated in to use .
Added a specific fallback strategy: if is 'inherit', try again with 'ignore' upon failure.
## Verification
This ensures that the tool (which uses ) benefits from the same robustness as other spawn sites in the codebase.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates process execution to route `runCommandWithTimeout` through the existing `spawnWithFallback` helper so it can recover from macOS Node 22+ `EBADF` when inheriting stdin in daemon/background contexts. It adds a targeted fallback that retries with `stdin: "ignore"` when the initial spawn uses `stdin: "inherit"`, and it also tweaks cron scheduling logic to ensure overdue jobs arm the timer immediately and one-shot jobs remain runnable until successfully completed.
<h3>Confidence Score: 4/5</h3>
- This PR looks safe to merge and aligns with existing spawn retry patterns, with only minor cleanup suggested.
- Core change (routing `runCommandWithTimeout` through `spawnWithFallback` and adding an stdin inherit→ignore retry) is consistent with existing `EBADF` handling and keeps behavior identical on success. The main actionable issue spotted is an unused `spawn` import that may fail lint/tsc, plus a small logging-consistency suggestion.
- src/process/exec.ts
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#6577: fix: add null checks for stdout/stderr when using inherit-stdio fal...
by ncmalan · 2026-02-01
81.2%
#9250: Fix: Add shell:true for Windows .cmd files to prevent spawn EINVAL ...
by vishaltandale00 · 2026-02-05
77.9%
#22721: fix(exec): keep child runs attached on macOS for reliable output
by rylena · 2026-02-21
77.4%
#6273: fix: handle EPIPE errors gracefully in daemon operations
by batumilove · 2026-02-01
76.7%
#23287: fix(node-host): improve ENOENT error when exec workspace dir is mis...
by SidQin-cyber · 2026-02-22
75.9%
#22813: Return clear error when exec cwd is missing instead of spawn ENOENT
by Clawborn · 2026-02-21
75.7%
#22812: fix(node-host): auto-create cwd before exec spawn to prevent mislea...
by aldoeliacim · 2026-02-21
75.3%
#3006: fix(scripts): use local pnpm binary in run-node.mjs if global is mi...
by elliotsecops · 2026-01-27
74.3%
#18112: fix(daemon): gateway install on macOS ignores fnm/nvm node (#18090)
by yinghaosang · 2026-02-16
74.1%
#9200: Fix: Strip dangerous env vars from baseEnv in host execution
by vishaltandale00 · 2026-02-05
73.5%