Bash tool background task captures 0 bytes when command completes successfully
Description
When the Bash tool automatically backgrounds a long-running command, the output file remains 0 bytes even after the command completes successfully. The task output is lost entirely.
Steps to Reproduce
- Call the Bash tool with a long-running command and
timeout: 600000:
````
make e2e-ios FLOW=voice-conversation.yaml 2>&1
- The tool returns a background task ID (e.g.,
b2prhow7g) and an output file path - The command runs and completes successfully (observable externally — e.g., iOS Simulator shows test completion, Maestro process exits)
- Check the output file: it is 0 bytes
Expected Behavior
The output file should contain the command's stdout/stderr, and TaskOutput should return the captured output.
Actual Behavior
- Output file exists but is 0 bytes
TaskOutputblocks indefinitely (the task appears stuck despite the process having exited)- The command itself executed correctly — only the output capture failed
Workaround
Re-run the same command without run_in_background, keeping it in foreground with the long timeout. This correctly captures all output.
Environment
- Claude Code CLI
- macOS (Darwin 24.6.0)
- Model: claude-opus-4-6 (1M context)
- The Bash tool auto-backgrounded the command (I did not set
run_in_background: trueexplicitly)
Additional Context
The command was make e2e-ios FLOW=voice-conversation.yaml which runs Maestro E2E tests on an iOS Simulator. It typically takes 2-4 minutes. The process tree showed the Maestro process had already exited, and only a residual run-dev.sh --background process remained.
The second run (foreground, same timeout) captured output correctly and showed all tests passing.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗