Linux Zombie & Orphan Process Forensics Prompt
Track down zombie (defunct) processes, runaway orphans, and broken parent-reaping so process tables don't fill and services stop leaking children.
- Target user
- Linux admins debugging process-tree and reaping issues
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux engineer who reads a process tree like a story and knows that a zombie is never the disease — it's a symptom of a parent that won't reap. I will provide: - `ps -eo pid,ppid,stat,wchan,cmd` (or the subtree of interest) showing the `Z`/`D`/`S` states - The symptom (growing defunct count, "fork: Resource temporarily unavailable", a service spawning children that never die, PID exhaustion) - The parent process and how it launches children (shell script, app with a broken `SIGCHLD` handler, a PID-1 in a container) - `cat /proc/sys/kernel/pid_max` and current process count - Whether this is a container (PID namespace, init reaping) or a normal host Your job: 1. **Decode the states** — explain `Z` (zombie/defunct: dead but unreaped), `D` (uninterruptible sleep: stuck in kernel I/O, often the real fire), `S`/`R`, and the `<`/`+`/`l` flags. Tell me which state is actually the problem. 2. **Zombies: blame the parent** — establish that you cannot kill a zombie (it's already dead); you must get its PARENT to `wait()`. Walk the diagnosis: find the PPID, determine why it isn't reaping (ignoring SIGCHLD, blocked in its own `D` state, or a buggy event loop), and fix or restart the parent. 3. **The reparent-to-init question** — when a parent dies, children reparent to PID 1 (or the subreaper). Explain why a container with a non-init PID 1 (like a bare app) accumulates zombies, and the fix (`--init`, tini, or `systemd` PID 1). 4. **Orphans & runaways** — distinguish harmless orphans from a fork-bomb-like leak; use `systemd-cgls`/cgroup accounting to attribute children to the right unit, and `TasksMax` to cap them. 5. **`D`-state deadlocks** — if processes are stuck uninterruptible, pivot to the I/O cause (`wchan`, NFS hang, dead device, frozen disk) — these don't respond to `kill -9` and signal a storage problem. 6. **PID exhaustion** — relate the leak to `pid_max` and "fork: Resource temporarily unavailable," and the per-user `nproc` limit. Output as: (a) which state is the real problem and why, (b) the offending parent PID and root cause of non-reaping, (c) exact remediation (signal/restart the parent, add an init/subreaper, set `TasksMax`), (d) a note on whether `kill -9` will help (for `Z`/`D` it won't), (e) a monitoring check on defunct count and process total. Anti-patterns to reject: `kill -9` on a zombie (it's already dead), rebooting to clear zombies instead of fixing the parent, ignoring `D`-state as if it were a zombie, and running an app as container PID 1 with no reaper.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Runtime Capability & Ambient Set Audit (getpcaps) Prompt
Audit what Linux capabilities a running process actually holds across its permitted/effective/inheritable/ambient/bounding sets, and decide whether a service is over-privileged or whether a 'permission denied' is a missing capability.
-
systemd Encrypted Credentials (systemd-creds) Design Prompt
Replace plaintext secrets in environment variables and EnvironmentFile= with TPM-backed or host-bound encrypted credentials delivered to units via systemd-creds and LoadCredentialEncrypted=.
-
systemd-nspawn and machinectl Container Management Prompt
Build, network, and lifecycle-manage lightweight OS containers with systemd-nspawn and machinectl for test environments without pulling in a full container runtime.
-
systemd-sysext Extension Image Management Prompt
Design and troubleshoot systemd-sysext system extension images so tools overlay onto an immutable or read-only base OS at runtime without modifying the underlying image.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.