Linux
Linux process management
Use explicit ownership and deterministic lifecycle transitions so every process can be safely identified, corrected, and recovered.
On this page
Doctrine
- Every service process maps to an ownership label and restart policy.
- Resource constraints must be explicit: memory, CPU, file descriptors, and forks.
- Graceful stop is preferred over kill-first behavior in all runbooks.
- Runbooks must define which state is normal, degraded, and failed.
Decision tree
- Is the process consuming unexpected resources?
- Yes → capture full process snapshot and test restart path under load.
- No → verify that process limits and privileges are already constrained.
- Can it be terminated safely?
- Yes → escalate from SIGTERM to SIGINT, then SIGKILL.
- No → isolate via cgroup/container boundary before process-level recovery.
- Is restart policy active and owned by supervisor?
- Yes → execute supervisor-managed restart to preserve audit state.
- No → recover ownership and avoid manual respawn loops.
Diagnostics pathway
- Identify runaway process and resource profile:
ps -eo pid,user,ppid,%cpu,%mem,cmd --sort=-%cpu | head - Inspect process tree and parent relations:
pstree -aps $(pgrep -f myservice) - Check open descriptors and sockets before termination:
lsof -p <pid> | head - Trace launch context and limits:
systemctl status myservice; systemctl show myservice --property=ExecStart,CPUQuota,MemoryMax
Operational checks
- Every process class has restart command, warm-recovery command, and data-safeness notes.
- Post-change, verify process identity user/group and cgroup assignment remain unchanged.
- Keep a 15-minute evidence window of before/after resource stats for postmortems.