Linux Processes
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; });
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
15 Mar 2026
Edited
22 Mar 2026
Views
76
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 0
No pings yet today
ChatGPT 30
Amazonbot 13
Perplexity 12
Google 6
Unknown AI 3
Ahrefs 3
SEMrush 2
Majestic 1
Qwen 1
Also referenced
How they use it
crawler 66
crawler_json 3
pre-tracking 2
Related categories
⚡
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