Bash tool: all commands return exit code 1 after sandbox process crash
Bug Description
All Bash tool invocations fail with Error: Exit code 1 after the internal sandbox shell subprocess crashes mid-session. This affects every command, including trivially infallible ones like true, echo "test", and pwd. The failure persists for the remainder of the session; only starting a new session recovers.
Reproduction
Not reliably reproducible on demand, but observed repeatedly during sessions with heavy parallel usage (multiple concurrent Claude Code sessions + subagents in the same repo). When it triggers:
⏺ Bash(echo "test")
⎿ Error: Exit code 1
⏺ Bash(true)
⎿ Error: Exit code 1
⏺ Bash(pwd)
⎿ Error: Exit code 1
Every Bash call fails identically. Non-Bash tools (Read, Glob, Grep, Edit) continue working normally.
Environment
- OS: macOS (Darwin 25.3.0)
- Shell: zsh
- Claude Code model: claude-opus-4-6
- Hooks configured: PreToolUse (session-guard on git/Edit/Write matchers), PostToolUse (async telemetry), Stop, SubagentStop
- Concurrent sessions at time of failure: 4+ Claude processes (main session + subagents across multiple git worktrees)
Analysis
- The hooks are not the cause — PreToolUse matchers are scoped to specific patterns (
Bash(git add*),Edit,Write, etc.) and do not match genericBash(echo *)orBash(true). - The exit code 1 is coming from the tool execution layer itself, not from the commands being run (since
truecannot exit non-zero). - Starting a new session immediately resolves the issue, confirming the sandbox subprocess died rather than a systemic OS/shell problem.
- Likely trigger: resource exhaustion (pty allocation, process tree depth, or internal sandbox state) under heavy parallel load.
Expected Behavior
Bash tool should either:
- Automatically detect and restart a dead sandbox subprocess, or
- Surface a clear error message ("Sandbox process died, please restart session") instead of misleading
Exit code 1on every command.
Workaround
Restart the Claude Code session. The new session gets a fresh sandbox and commands work immediately.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗