Pcornel
Linux · Processes

PID / PPID

Cheat sheet · https://pcornel.dk/topic.php?topic=2715

Back to the Topic

Answer

Each process has a PID (process ID) and a PPID (its parent's PID). PID 1 is the init system. PIDs are reused after a process exits.

Remember

Do not rely on a stale PID file — the PID may now belong to another process. Use pgrep, systemctl show -p MainPID <unit> or pidof to get the current PID.

First checks

  • ps -eo pid,ppid,user,stat,%cpu,%mem,etime,cmd --sort=-%cpu | head — processes by CPU with parent and state
  • pstree -p <pid> — process tree
  • top / htop — live CPU and memory
  • cat /proc/<pid>/status — state, threads and memory of one process

Commands

docker run --init

Verify in this order

process created with a new PID → PPID records its parent → PID released at exit and may be reused

Where it usually breaks

First mismatch in hardware/kernel capability → scheduler/mm/device → cgroup/namespace → process/thread → service/runtime → workload behavior/counters; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2715

Confirmation

Confirm action

Continue?