Expand description
G28: orphan-process reaper that runs at CLI startup. G28: Reaper for orphan external processes.
When the CLI crashes or is killed (SIGKILL, OOM, machine reset), child
processes spawned by claude -p or codex exec may be left running.
Without cleanup they accumulate as zombies that consume CPU, RAM, and
MCP-spawned subprocess trees (the 2026-06-03 incident: 1.877 processes
total, load average 276 on a 10-CPU host).
[scan_and_kill_orphans] walks the process table at startup and
terminates any claude or codex invocation whose PPID is 1
(reparented to init/launchd after the parent died) and that is
older than the ORPHAN_MIN_AGE_SECS constant. The scan is conservative: it only
kills processes that (a) match a known LLM CLI name, AND (b) are
orphaned, AND (c) are older than the threshold. A short-lived CLI
that is just starting up is left alone.
Structs§
Functions§
- scan_
and_ kill_ orphans - Walks the process table and kills orphan LLM invocations.