Lesson 4 of 14 · 20m
Processes, Signals, and Job Control
Ctrl-C sends SIGINT to a process group, `kill` is a request while `kill -9` is a kernel reap, and exit 137 means the OOM-killer chose you.
Ctrl-C doesn't kill a process. It sends SIGINT to the foreground process group attached to your terminal — which is why Ctrl-C on a pipeline sometimes leaves a stage running, and why kill is a request, not a verdict. Signals are the actual mechanism, and they explain almost every confusing process state you'll meet.
The signals that matter
SIGINT(2) — Ctrl-C. Asks for interrupt; programs may catch it and clean up.SIGTERM(15) — the defaultkillsends. A polite request: handlers run,finally/atexitblocks execute, temp files get removed.SIGKILL(9) — the kernel reaps the process. It cannot be caught, blocked, or ignored. No cleanup of any kind: nofinally, no buffer flush, no lock release.kill -9on a process mid-write is how you get truncated databases — it's the last resort, not the default.SIGHUP(1) — "your terminal hung up." Historically kills shell children on logout; daemons repurpose it as a reload signal.SIGTSTP— Ctrl-Z. Suspend, not terminate.
Exit status encodes the signal: 128 + n. A script exiting 130 was SIGINT'd. Exiting 137 means SIGKILL — and on a memory-pressured Linux box, 137 at 02:00 with no log output means the OOM-killer did it. dmesg -T | grep -i oom names the victim. This is a real first-look check, not trivia.
Job control
cmd &— start in the background;$!holds its PID.Ctrl-Zthenbg— suspend, resume in background.fg %1brings job 1 back.jobs— list the shell's jobs.%1,%2reference them.disown %1— remove the job from the shell's table so it survives logout; without it, a suspended background job gets SIGHUP when you disconnect and dies anyway.nohup cmd &— the pre-tmux answer: ignore SIGHUP, write output tonohup.out.wait— in a script, block until background children finish;wait $!for a specific one.
The mental model to reject: "backgrounded means detached." A background job is still your shell's child attached to your terminal — only disown, nohup, or a multiplexer (tmux) actually severs the hangup path.
Seeing what's running
ps aux(BSD syntax) vsps -ef(SysV) — both still used;ps auxfdraws the tree, which is what you actually want when a process spawned helpers.pgrep -fl name,pkill -f pattern— find and signal by name;killallexists, but on Solaris it kills everything, which is whypkillis the habit.kill -- -PGID— signal a whole process group; how you take down a pipeline that spawned helpers.lsof -ti :3000— the PID listening on a port;killport() { lsof -ti :"$1" | xargs -r kill; }is the function that answers "what's holding 3000."/proc/<pid>/on Linux:cmdline,cwd,environ,fd/— the process's real state, readable as files.strace -p <pid>— attach to a hung process and watch the syscall it's parked in. A blockedconnect()on a dead host or anflockit will never get is usually the whole answer.<defunct>zombies are already dead — their parent neverwait()ed on them. You can't kill them; the fix is in the parent.
Practice
kill(TERM) first;-9only after the process proved it won't exit cleanly.- Wrap every unattended job:
timeout 300 cmdbounds runtime,flock -n /tmp/job.lock cmdprevents pileups. - Read exit codes:
137→ checkdmesgfor OOM;130→ interrupted. disownor tmux for anything that must outlive your ssh session.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Red Hat Called This Bug a 5.9. Two Weeks Later It Was a 9.8.
CVE-2026-98432 is a use-after-free in the IPv4 TCP handshake, reachable by anybody who can reach a listening port, sitting in the kernel since 4.4. Red Hat scored it 5.9 moderate and deferred the fix. Then 8.1. Then 9.8.
Self-Host OpenClaw: VPS Setup to Production (2026)
Self-host OpenClaw from zero to production. Server provisioning, SSH lockdown, Docker, reverse proxy, Fail2ban, performance tuning, and full backup strategy in one guide.
Self-Hosting Prometheus and Grafana: Infrastructure Monitoring That Actually Works
Build a production-grade monitoring stack with Prometheus and Grafana from scratch. Covers architecture, Docker Compose deployment, Node Exporter, alerting with Alertmanager, PromQL from basics to advanced, pre-built dashboards, and everything SudoSecurity uses to monitor its own infrastructure.
Zero Trust Everything: The Complete Guide to Self-Hosting Teleport for Secure Infrastructure Access
SudoSecurity runs Teleport internally for everything — admin panel access, secure database connections, Kubernetes, and zero-trust philosophy across our entire team. This is the complete technical guide to installing, configuring, and running your own self-hosted Teleport cluster from scratch.