Linux Processes
debt(d5/e3/b5/t5)
Closest to 'specialist tool catches it' (d5). The detection_hints list htop, ps, strace, and perf — all specialist/observability tools rather than compiler or default linter checks. Issues like zombie processes, runaway CPU/memory, or workers not being reaped are visible only when you know to look with these tools; they don't surface automatically in normal development flow.
Closest to 'simple parameterised fix' (e3). The quick_fix describes using ps/top/htop to identify runaway processes and setting memory_limit/max_execution_time in php.ini. Fixing signal handling in queue workers or correcting kill usage is a small, targeted change — not a single one-liner but well within one component and not cross-cutting.
Closest to 'persistent productivity tax' (b5). The term applies_to both web and cli contexts (PHP-FPM and queue workers), meaning process/signal awareness shapes how workers are written, how deployments handle reloads, and how debugging is done across multiple work streams. It is not architecturally defining but imposes an ongoing tax on anyone managing PHP in production.
Closest to 'notable trap' (t5). The misconception field explicitly documents the canonical gotcha: developers assume kill sends SIGKILL and terminates immediately, but it actually sends SIGTERM requesting graceful shutdown. This is a well-documented but commonly encountered surprise, especially for developers from non-Unix backgrounds. The common_mistakes reinforce this (kill -9 as first option, not handling SIGTERM in workers).
Also Known As
TL;DR
Explanation
Each process has a PID (process ID), parent PID (PPID), memory map, open file descriptors, and a signal mask. Key tools: ps aux (snapshot of all processes), top/htop (live view), kill -SIGNAL PID (send signal), strace (trace system calls), lsof (open files per process). Signals: SIGTERM (graceful shutdown request), SIGKILL (immediate termination, cannot be caught), SIGHUP (reload config), SIGUSR1/SIGUSR2 (custom). PHP-FPM responds to SIGTERM for graceful shutdown and SIGUSR2 for reload.
Common Misconception
Why It Matters
Common Mistakes
- Using kill -9 as the first option — SIGKILL prevents cleanup, open file handles stay open, transactions may be left incomplete.
- Not handling SIGTERM in queue workers — workers killed mid-job corrupt the queue state.
- ps aux grep includes the grep process itself in results — use ps aux | grep [p]rocess to exclude it.
- Not knowing that zombie processes are already dead — they are waiting for the parent to read their exit code; kill the parent or fix the parent to wait().
Code Examples
# Brutal kill — no cleanup, potential data loss:
kill -9 $(pgrep php-fpm) # Immediately kills all FPM workers
# Active requests terminated mid-execution
# DB transactions left open
# Temp files not cleaned up
# Graceful PHP-FPM reload (zero-downtime):
kill -USR2 $(cat /var/run/php-fpm.pid) # Reload config, finish active requests
# Graceful shutdown (waits for active requests):
kill -TERM $(cat /var/run/php-fpm.pid) # SIGTERM — graceful
# Monitor:
watch -n1 'ps aux | grep php-fpm | grep -v grep'
# Queue worker: handle SIGTERM gracefully in PHP:
pcntl_async_signals(true);
pcntl_signal(SIGTERM, function() use (&$running) { $running = false; });