Claude Code freezes in infinite CPU loop after background process is killed

Resolved 💬 2 comments Opened Jan 20, 2026 by andrewyager Closed Jan 20, 2026

Bug Report: Claude Code freezes in infinite CPU loop after process ends unexpectedly

Summary

Claude Code 2.1.12 becomes unresponsive and consumes 100% CPU after a bash command's child process terminates. The process appears to be stuck in an infinite loop, possibly related to pkill/pgrep process cleanup logic.

Environment

  • Claude Code Version: 2.1.12
  • OS: macOS 26.2 (Darwin 25.2.0)
  • Architecture: ARM64 (Apple Silicon)
  • Shell: zsh

Steps to Reproduce

Most Reliable Reproduction (reported pattern)

  1. Run Claude Code
  2. Start a remote/background process via bash (e.g., command & or a process that backgrounds itself)
  3. Kill the backgrounded process
  4. Claude Code freezes at 100% CPU

Alternative Reproduction (observed in this instance)

  1. Run Claude Code in a project directory
  2. Execute a bash command that processes a large file (in this case, strings on a 15MB binary file piped through grep)
  3. The command completes (child process becomes zombie/defunct)
  4. Claude Code freezes at 100% CPU

Observed Behavior

  • Process state: R+ (running in foreground, not blocked on I/O)
  • CPU usage: 100% continuously
  • A zombie child process exists (the bash command completed but wasn't reaped)
  • The main thread is stuck in JIT-compiled JavaScript code (infinite loop)

Expected Behavior

Claude Code should handle process termination gracefully and continue normal operation.

Diagnostic Information

Process State

PID   PPID  STAT  COMMAND
52315 52974 R+    claude
52856 52315 Z     <defunct>   # Zombie child - bash command completed

CPU/Memory Usage

PID   %CPU  %MEM  ELAPSED   TIME
52315 100.1 1.9   04:49     3:32.00

Last Command Before Freeze

strings -n 4 "/path/to/file.bin" | grep -iE "pattern" | sort -u

Call Stack Sample (via sample command)

All 8265 samples (100%) are in the same call path through JIT-compiled JavaScript code, indicating an infinite loop:

8265 Thread_1347924  DispatchQueue_1: com.apple.main-thread (serial)
+ 8265 start (in dyld)
+   8265 ??? (in 2.1.12) [JIT code]
+     ... [deep JIT call stack - all samples in same path]

Related Processes

  • clangd MCP server running (PID 52332)
  • caffeinate process active (PID 52778)

Suspected Cause

Based on previous observations, this appears to be related to process cleanup logic (possibly pkill/pgrep) that enters an infinite loop when a child process terminates unexpectedly or in an unusual state.

Workaround

Kill the frozen Claude Code process and restart:

kill -9 <pid>

Additional Context

  • This is a recurring issue that has been observed multiple times
  • The pattern seems consistent: bash command completes, child becomes zombie, Claude freezes
  • The freeze happens in the main thread, not in child process handling

Attachments

  • Full sample output available upon request
  • Conversation log from frozen session available

View original on GitHub ↗

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