← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

Linux Processes

Linux PHP 5.0+ Intermediate
debt(d5/e3/b5/t5)
d5 Detectability Operational debt — how invisible misuse is to your safety net

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.

e3 Effort Remediation debt — work required to fix once spotted

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.

b5 Burden Structural debt — long-term weight of choosing wrong

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.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

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).

About DEBT scoring →

Also Known As

PID process management signals kill command

TL;DR

Every running program is a process with a PID, memory space, and file descriptors — ps, top, kill, and signals are the essential tools for managing them.

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

kill kills a process immediately — kill sends SIGTERM by default, which asks the process to shut down gracefully; only kill -9 (SIGKILL) forces immediate termination.

Why It Matters

Understanding signals is essential for zero-downtime PHP-FPM reloads, graceful queue worker shutdown, and diagnosing hung processes — kill -9 should always be the last resort.

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

✗ Vulnerable
# 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
✓ Fixed
# 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; });

Added 15 Mar 2026
Edited 22 Mar 2026
Views 127
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
1 ping T 1 ping W 3 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 2 pings W 2 pings T 4 pings F 2 pings S 4 pings S 4 pings M 1 ping T 4 pings W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W
No pings yet today
No pings yesterday
ChatGPT 42 Scrapy 18 Amazonbot 16 Perplexity 16 Google 7 Ahrefs 5 SEMrush 4 Unknown AI 3 Claude 2 Majestic 1 Qwen 1 Meta AI 1 PetalBot 1
crawler 108 crawler_json 7 pre-tracking 2
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Low
⚡ Quick Fix
Use ps aux, top, or htop to identify runaway PHP processes; set memory_limit and max_execution_time in php.ini to prevent resource exhaustion
📦 Applies To
PHP 5.0+ web cli
🔗 Prerequisites
🔍 Detection Hints
PHP process consuming 100% CPU or memory; zombie processes; PHP-FPM workers not being reaped
Auto-detectable: ✓ Yes htop ps strace perf
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: Medium Context: File


✓ schema.org compliant