claude-code - 💡(How to fix) Fix [Bug] Hook subprocess cleanup causes 100% CPU freeze on task interruption [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55609Fetched 2026-05-03 04:49:01
View on GitHub
Comments
3
Participants
2
Timeline
14
Reactions
0
Author
Timeline (top)
labeled ×6commented ×3cross-referenced ×3mentioned ×1

Root Cause

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.

Code Example

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
RAW_BUFFERClick to expand / collapse

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.

extent analysis

TL;DR

Disable or remove hooks configured in ~/.claude/settings.json to potentially resolve the 100% CPU freeze issue.

Guidance

  • Verify the hypothesis by running the provided 5-minute test to see if the freeze stops with vanilla settings and reproduces with hooks.
  • Check the ~/.claude/settings.json file for any shell scripts or custom hooks that may be causing the issue.
  • Try removing or disabling individual hooks one by one to identify the specific hook causing the problem.
  • Consider sharing the forensic capture from 2026-05-02 for further analysis.

Example

No code snippet is provided as it is not clearly supported by the issue.

Notes

The issue seems to be related to the hook-subprocess and interrupt cleanup path, and the provided test can help confirm this hypothesis. The fact that vanilla claude installs with no hooks seem less likely to trigger the issue suggests that the problem is indeed related to the hooks.

Recommendation

Apply workaround: Disable or remove hooks configured in ~/.claude/settings.json to potentially resolve the 100% CPU freeze issue. This is because the issue seems to be related to the hooks, and disabling or removing them may prevent the freeze from occurring.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING