anthropics / anthropics/claude-code
Headless claude -p deadlocks in uninterruptible openat on macOS; interactive sessions unaffected
- Dominant language
- Python
- Stars
- 145k
- Forks
- 23.1k
- PR merge metrics
- PR metrics pending
Description
**Date:** 2026-08-24
## Summary
Every headless invocation (`claude -p`) on this machine deadlocks partway into the session:
main thread blocked forever in `openat$NOCANCEL`, 0% CPU, no TCP connections, no child
processes. Interactive sessions on the same machine, same account, are unaffected.
8/8 reproductions: 5 via a no-mistakes pipeline daemon spawning `claude -p --output-format
stream-json --json-schema ... --dangerously-skip-permissions`, and 3 spawned directly from a
shell with stdout redirected to a file (with and without `--debug`, with and without
`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`).
## Signature
- `sample `: main thread parked in `openat$NOCANCEL` (1500+/1500+ samples), JIT (JS)
frames above; worker threads idle in `kevent64`/pool waits.
- No TCP sockets open (`lsof`); not a network hang.
- No child processes; not a tool-subprocess hang.
- `SIGKILL` sometimes fails to reap the process (uninterruptible syscall).
- Freeze point varies by run: after ~2 tool rounds (transcript event 19, last =
`total_tokens_reminder` attachment), at `ai-title` (event 9), or at `atis-latch` (event 20).
Always coincides with concurrent background activity (session-title request in flight,
statsig/bootstrap fetch, atomic `~/.claude.json` rewrite).
- With `--debug`: log stops mid-stream right after two concurrent `/v1/messages` requests
(`source=generate_session_title` + `source=sdk`) both received first bytes.
## Ruled out
- no-mistakes daemon (reproduces with plain `claude -p` from a shell)
- claude version regression (2.1.235 and 2.1.241 both freeze)
- permission-prompt deadlock (`--dangerously-skip-permissions` present in pipeline repros)
- stdout backpressure (reproduces with stdout redirected to a regular file)
- hung file provider (Google Drive + fileproviderd restarted; CloudStorage lists fine)
- FIFOs / dead symlinks in cwd, skills, agents, plugins trees (none exist)
- keychain-db file locks (no holders)
- nonessential traffic (`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` still freezes)
## Not yet done (needs sudo)
`fs_usage`/`spindump` or lldb attach to capture the blocked path argument — lldb attach is
denied by SIP for a same-user attach on this machine.
## Repro
```
cd
echo 'Read README.md, then read pyproject.toml, then reply with one sentence.' | claude -p
# hangs forever; sample the pid to see openat$NOCANCEL
```
## Impact
Any local tooling that drives `claude -p` (review pipelines, cron jobs, CI-style local gates)
wedges silently. Workaround in use: pipeline agent switched to codex; Claude review still
applied via GitHub Actions (claude-review.yml) and interactive sessions.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the `claude -p` reproduction command from any Git repository and capture `--debug` output alongside `fs_usage`, `spindump`, or an lldb attach as described. Compare the headless path with the interactive session and the `claude-review.yml` workflow; done means the reported macOS invocation no longer deadlocks in `openat$NOCANCEL`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, macos
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100