SessionStart hook with background process silently blocks claude-code after v2.1.87
Resolved 💬 3 comments Opened Apr 3, 2026 by edgehu Closed Apr 7, 2026
Description
After updating to Claude Code 2.1.87, the Code mode in Claude Desktop became completely unresponsive when a SessionStart hook contained a background process (caffeinate -s &).
Root Cause
The background process (caffeinate -s &) inherits the parent process's stdin/stdout file descriptors. Since claude-code communicates with the Desktop App via stream-json through these pipes, the background process holding them open caused claude-code to wait indefinitely.
This behavior was tolerated in previous versions but became fatal after 2.1.87 tightened the subprocess communication mechanism.
Symptoms
- Code mode produces no response after message is submitted
- Chat and Cowork modes work normally
- Log shows:
Session timed out after 649s (hadFirstResponse=false, reason=no_response) - Subprocess starts but
seconds_since_stderr=never
Workaround
Use nohup with full file descriptor cutoff:
nohup caffeinate -s </dev/null >/dev/null 2>&1 & echo $! > ~/.claude/caffeinate.pid
Suggested Improvements
- When a hook causes claude-code to hang on first response, surface an error message instead of silently timing out
- Add documentation warning: hook commands must not inherit parent's stdin/stdout — recommend
nohup ... </dev/null >/dev/null 2>&1 &for background processes - Include a changelog note when hook execution environment changes between versions
Environment
- Claude Code: 2.1.87
- OS: macOS (Apple Silicon)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗