Headless: `claude -p -r <session_id>` combined with stdin input hangs indefinitely; argv positional works
Open 💬 0 comments Opened Jul 2, 2026 by discorder256
Version: 2.1.198 (Claude Code CLI, Linux/WSL2)
Summary: Resuming a headless session (-r <session_id>) while piping the user turn via stdin hangs indefinitely (observed 90s+ with zero output, reproduced twice). The identical resume with the user turn passed as an argv positional works reliably (verified across a 40-turn chained run).
Repro (toy):
claude -p "start a session" --output-format json→ capturesession_id.echo "next turn" | claude -p -r <session_id>→ hangs, no output.claude -p -r <session_id> "next turn"→ works.
Expected: stdin input to behave the same on resumed sessions as on fresh ones (fresh claude -p accepts piped stdin fine), or an explicit error if unsupported.
Impact: breaks scripted multi-turn headless pipelines that pipe input; workaround exists (pass the turn as argv).