Agent-skills process-cleanup
This skill should be used when the user asks to "find zombies", "kill zombie processes", "clean up zombies", "check for zombie processes", "reap zombies", or mentions zombie process detection, cleanup, or process state monitoring.
install
source · Clone the upstream repo
git clone https://github.com/PaulRBerg/agent-skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/PaulRBerg/agent-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/process-cleanup" ~/.claude/skills/paulrberg-agent-skills-process-cleanup && rm -rf "$T"
manifest:
skills/process-cleanup/SKILL.mdsource content
Process Cleanup
Detect and reap zombie processes using
/bin/ps.
Background
A zombie (state
Z) is a process that has exited but whose parent hasn't called wait() to collect its exit status. Zombies consume no CPU or memory, but they hold a PID slot and can accumulate. You can't kill a zombie — it's already dead. The only remedies are:
- Signal the parent with
so it reaps the childSIGCHLD - Kill the parent so
/init
adopts and reaps the orphanlaunchd
Important: use ps
for process state queries
psAlways use
ps (BSD) for process state queries. If ps is aliased, use /bin/ps to bypass it.
# List zombies /bin/ps ax -o pid,state,ppid,user,command | awk '$2 ~ /Z/' # List all processes with state /bin/ps ax -o pid,state,ppid,etime,args
Usage
Run the helper script to scan for zombies:
# Detect only (default) — list zombie processes bash scripts/kill-zombies.sh # Reap zombies — send SIGCHLD to parent processes bash scripts/kill-zombies.sh --kill
Safety
- Default mode is detect-only — no processes are signaled
- With
, the script sends--kill
to parent processes (non-destructive nudge to reap)SIGCHLD - If a parent ignores
, the script reports the parent PID — confirm with the user before killing itSIGCHLD - Never kill PID 1 (
/init
)launchd