claude-code - 💡(How to fix) Fix [BUG] CLI process orphans at 100% CPU after window/terminal close (2.1.111, 2.1.121)

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…

After closing the host terminal or Claude.app window, the claude CLI process is sometimes orphaned (PPID=1) and stays at ~100% CPU indefinitely. The session ended cleanly (last transcript entry is a normal assistant reply, all tool_use paired with tool_result), but the event loop never exits.

Error Message

Error Messages/Logs

Root Cause

After closing the host terminal or Claude.app window, the claude CLI process is sometimes orphaned (PPID=1) and stays at ~100% CPU indefinitely. The session ended cleanly (last transcript entry is a normal assistant reply, all tool_use paired with tool_result), but the event loop never exits.

Fix Action

Workaround

LaunchAgent runs hourly and kills MacOS/claude processes with PPID=1 AND %CPU>50. Active sessions are safe (they have non-1 PPID).

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

After closing the terminal or Claude.app window without /exit, the claude CLI process is orphaned (PPID=1) and stays at ~100% CPU indefinitely. Last transcript entry is a normal assistant reply with all tool_use paired with tool_result — session ended cleanly but the event loop never exits. Found 3 such zombies on my system over 8 days; worst case ran 184 CPU-hours.

Summary

After closing the host terminal or Claude.app window, the claude CLI process is sometimes orphaned (PPID=1) and stays at ~100% CPU indefinitely. The session ended cleanly (last transcript entry is a normal assistant reply, all tool_use paired with tool_result), but the event loop never exits.

Versions affected

  • 2.1.111
  • 2.1.121
  • macOS (Apple Silicon, latest)

Evidence

Found 3 zombie processes over 8 days. Worst case lived 8 days at ~100% CPU (184 CPU-hours) after a session that ended normally on 2026-04-27 19:37 — no interruption, no unfinished tool calls in the transcript. Sample ps output:

  • PID 14051, PPID=1, 99.2% CPU, 16h elapsed, claude-code 2.1.121
  • PID 47432, PPID=1, 99.6% CPU, 8d 15h elapsed, claude-code 2.1.111 All zombies share: PPID=1 (parent died), high CPU, no further activity in the JSONL transcript.

Reproduction

Not 100% deterministic, but suspected trigger: closing the host (terminal window or Claude.app) without /exit. Possibly related to stdin/stdout handling on parent death — the process doesn't seem to receive or honor SIGHUP.

Impact

  • Drains CPU/battery silently
  • Multiplies over time if user doesn't notice (3 zombies × ~100% CPU = 3 cores wasted)

Workaround

LaunchAgent runs hourly and kills MacOS/claude processes with PPID=1 AND %CPU>50. Active sessions are safe (they have non-1 PPID).

Suggested fix

  • Trap SIGHUP / SIGPIPE in the CLI's main event loop and exit cleanly
  • Or: detect closed stdin and exit

What Should Happen?

When the parent process (terminal or Claude.app window) closes, the claude CLI process should receive SIGHUP and exit cleanly within seconds.

Error Messages/Logs

Steps to Reproduce

  1. Open a Claude Code session in Claude.app or a terminal
  2. Have a normal exchange (or several)
  3. Close the host window/terminal directly (X button, Cmd+Q) without typing /exit
  4. Run: ps -axo pid,ppid,%cpu,command | grep MacOS/claude
  5. Observe: claude process still running with PPID=1 and high CPU Not 100% deterministic — happened ~3 times over 8 days of regular use.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Claude Code: 2.1.111 and 2.1.121 (both affected)

Claude Code Version

1.5354.0

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

logs:

ps -axo pid,ppid,%cpu,etime,command | grep MacOS/claude 14051 1 99.2 16:17:11 ...claude-code/2.1.121/.../MacOS/claude 47432 1 99.6 8-15:00 ...claude-code/2.1.111/.../MacOS/claude

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

claude-code - 💡(How to fix) Fix [BUG] CLI process orphans at 100% CPU after window/terminal close (2.1.111, 2.1.121)