Linux

Linux process management

Use explicit ownership and deterministic lifecycle transitions so every process can be safely identified, corrected, and recovered.

On this page

  1. Doctrine
  2. Decision tree
  3. Diagnostics pathway
  4. Operational checks
  5. Related routes

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

  1. 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.
  2. Can it be terminated safely?
    • Yes → escalate from SIGTERM to SIGINT, then SIGKILL.
    • No → isolate via cgroup/container boundary before process-level recovery.
  3. 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

  1. Identify runaway process and resource profile:
    ps -eo pid,user,ppid,%cpu,%mem,cmd --sort=-%cpu | head
  2. Inspect process tree and parent relations:
    pstree -aps $(pgrep -f myservice)
  3. Check open descriptors and sockets before termination:
    lsof -p <pid> | head
  4. 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.