Orphaned Claude Code process enters 100% CPU busy loop when parent terminal is closed

Resolved 💬 3 comments Opened Apr 14, 2026 by goneforalone Closed Apr 14, 2026

Description

When the terminal (iTerm2) window/tab that launched a Claude Code desktop app session is closed, the claude process becomes orphaned (reparented to launchd PID 1) and enters a 100% CPU busy loop instead of gracefully terminating.

Steps to reproduce

  1. Launch Claude Code from the desktop app (Claude.app) — it spawns a claude CLI process
  2. Close the terminal/tab that hosts the session (or close the desktop app window)
  3. The claude process does not terminate — it gets reparented to launchd (PPID=1)
  4. The process enters a CPU-bound busy loop consuming ~100% of one core indefinitely

Observed behavior

  • Process consumed 101% CPU for 17+ hours after the parent terminal was closed
  • SIGTERM was ignored — only SIGKILL terminated it
  • sample output showed the main thread in a tight loop with no I/O waits — pure busy spinning
  • A zombie child process (<defunct>) was present, suggesting lifecycle management broke down
  • No network connections were open — the process was not communicating with the API

Expected behavior

The claude process should detect that its parent terminal/stdin is gone and either:

  • Gracefully shut down, or
  • At minimum, stop consuming CPU (idle/sleep)

It should also respond to SIGTERM.

Environment

  • OS: macOS 26.2 (Darwin 25.2.0), Apple M5
  • Claude Code version: 2.1.92
  • Terminal: iTerm2 3.6.x
  • Launch method: Claude.app desktop → CLI process with --output-format stream-json

Process details (from investigation)

PID:     65585
PPID:    1 (launchd — orphaned)
Command: claude --output-format stream-json --verbose --input-format stream-json
         --effort high --model claude-opus-4-6[1m]
         --resume 3ab1600e-95fd-4443-b5a2-e8170967ef5c
         --permission-mode acceptEdits --allow-dangerously-skip-permissions
Started: Mon Apr 13 18:57:49 2026
Uptime:  17h 35m at time of kill
CPU:     101% (constant)
RAM:     ~474 MB peak
State:   R (running, not sleeping)
Children:
  - glab mcp serve (PID 65593, healthy, 0% CPU)
  - <defunct> zombie (PID 65650)

View original on GitHub ↗

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