[Bug] Hook subprocess cleanup causes 100% CPU freeze on task interruption

Resolved 💬 6 comments Opened May 2, 2026 by boshu2 Closed Jun 30, 2026

Bug Description

Refining the repro for the long-running 100% CPU freeze in 2.1.x (cross-ref public issues #27415 and #18532).

I now think this is hook-related, not just TaskStop-related.

Repro (4 steps, ~60 sec):

  1. Have any hook configured in ~/.claude/settings.json (SessionStart / SessionEnd / Stop / PreToolUse / PostToolUse — especially ones running shell scripts)
  2. Start a Claude session
  3. Run any backgrounded bash tool
  4. Interrupt — Ctrl-C, ask Claude to kill the task, or close the tab while the tool is mid-flight

100% CPU spin every time, force-kill required. Vanilla claude installs with no hooks seem much less likely to trigger.

5-minute test for the hypothesis (anyone on your team can run this):

mv ~/.claude/settings.json ~/.claude/settings.backup.json
echo '{}' > ~/.claude/settings.json
claude
# (run + interrupt a backgrounded task)
mv ~/.claude/settings.backup.json ~/.claude/settings.json

If freeze stops with vanilla settings and reproduces with hooks, root cause is in the hook-subprocess + interrupt cleanup path. That would also explain why engineers on stock dev boxes don't reproduce on the first try, while users with AgentOps / custom MCP / status-line wrappers hit it daily.

I have a fresh forensic capture from 2026-05-02: independent 1Hz monitor logged the entire userland stalling for 24 seconds during the freeze. macOS 26.4.1 / M5 / 32 GB / claude 2.1.126. Happy to share.

Environment Info

  • Platform: darwin
  • Terminal: ghostty
  • Version: 2.1.126
  • Feedback ID: 53400c39-c176-4667-83ae-be548fa1e5d6

Note on auto-attached errors: the in-app /bug flow auto-attached two prompt is too long: 1006407 tokens > 1000000 maximum errors. Those are unrelated to this bug — they're context-overflow errors from a long-running session in this same window. They're not part of the freeze repro. Stripped from this issue body to avoid confusing the diagnosis.

Disclosure: I build AgentOps on top of Claude Code; filing as a daily user.

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗