Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 2.35 KB

File metadata and controls

66 lines (45 loc) · 2.35 KB

Processes, Signals, and Resource Limits

← Guide index · Repository home

Overview

A process has identity, parentage, open resources, scheduling state, environment, and limits. Reliable diagnosis asks what the process is waiting for before attempting to restart it.

Caution

Inspect targets and understand impact before running privileged or mutating commands. Test changes in a safe environment first.

Operational Scenario

A worker stops consuming jobs. The investigation checks whether it is running, blocked on I/O, exhausting file descriptors, repeatedly crashing, or waiting on a dependency.

Core Concepts

# Working principle
1 Process state distinguishes running, sleeping, stopped, and zombie tasks.
2 Signals request behavior; SIGTERM allows cleanup while SIGKILL does not.
3 Resource limits constrain files, processes, memory locking, and other per-process capabilities.

Investigation Commands

pgrep -a order-worker
ps -o pid,ppid,user,stat,lstart,etime,%cpu,%mem,cmd -p 1234
cat /proc/1234/status
ls -l /proc/1234/fd | head
cat /proc/1234/limits
kill -TERM 1234

Commands are examples for observation and controlled testing. Paths, process identifiers, interfaces, and service names must be adapted to the actual host.

Practical Workflow

  1. Define the symptom, affected users, and time window.
  2. Collect the smallest useful set of host and service evidence.
  3. Form one falsifiable hypothesis.
  4. Make the least disruptive test or change.
  5. Verify recovery and record what was learned.

Production Practices

  • Send SIGTERM and allow the documented shutdown window before escalation.
  • Use systemd or the owning supervisor instead of manually replacing managed processes.
  • Capture logs and process state before restarting when incident evidence matters.

Common Mistakes

  • Using kill -9 as the first response.
  • Treating a zombie as a CPU-consuming process.
  • Reading process environment without considering secret exposure.

Interview and Review Questions

  1. What creates a zombie process?
  2. Why is SIGTERM preferred to SIGKILL?
  3. How would you investigate file-descriptor exhaustion?

References