Claude Code Left 10 Orphaned Busy-Loops Burning a Laptop's CPU
A Claude Code session left 10 orphaned busy-loops running for two days, pegging CPU. Here's how it was diagnosed and fixed.
A Claude Code session spawned ten CPU-saturating shell loops meant to stress-test an integration suite, then failed to clean them up. Two days later, all ten were still running, reparented to PID 1, pinning a 10-core machine's load average well above 120 while the fan ran flat out.
The root cause is a common shell-scripting mistake: the cleanup relied on `jobs -p` to collect background PIDs, which silently returns nothing in a non-interactive shell because job control is off. Compounding that, the parent shell exited before ever reaching the kill line, so there was no fallback path to catch the leftovers.
Diagnosis came down to standard process inspection: checking load average against core count, sorting by CPU with ps, and pulling full arguments for any process with PPID 1 and a multi-day elapsed time — since the command name alone (zsh, node) reveals nothing about intent. The fix itself was a plain kill, no signals needed.
The broader lesson for anyone running agentic coding tools: agents execute real, resource-consuming commands, and a crashed or cancelled session does not guarantee its children die with it. Collecting PIDs via `$!` and wrapping cleanup in a trap for EXIT/INT/TERM would have prevented this entirely.