Processes in Practice
The problem
Running programs need to be inspected, controlled, and sometimes forcibly stopped from the shell — without practical tools to list, signal, and manage processes, a hung or runaway program can only be fixed by rebooting the entire machine.
Why now
Processes and threads, and system calls and the kernel, already covered what a process is and how it talks to the kernel; this topic is the practical, hands-on application of that theory — the actual commands used to observe and control the processes those earlier topics only described abstractly.
Mental model
Every running process has a PID (a simple integer identity) and a state (running, sleeping, stopped). ps and top let you look at that state; kill doesn't actually 'kill' by force — it sends a signal (a simple, standardized interrupt message) that the target process can catch, ignore, or die from, which is why some processes need SIGKILL instead of the gentler SIGTERM to actually stop.
Requires
- Processes & ThreadsOperating Systems
Every command in this topic (ps, kill, top) directly inspects or manipulates the process abstraction processes-and-threads defines; without that concept there's nothing for these tools to operate on.
- System Calls & the KernelOperating Systems
Sending a signal to a process (kill) and listing running processes (ps) are both mediated by system calls into the kernel's process table — the same user-mode/kernel-mode boundary already established.
Used in
- Debugging a hung or runaway program on any server
- Monitoring resource usage (top, htop) to identify what's consuming CPU or memory
- Graceful shutdown handling in deployed services (catching SIGTERM to clean up before exit)
- Process supervisors (systemd, PM2) that restart crashed processes automatically
Projects
- Start a long-running background process, find its PID with ps, and terminate it with kill, observing the difference between SIGTERM and SIGKILL
- Use top or htop to identify the most CPU- and memory-intensive processes currently running on your machine
Examples
- kill -9 <pid> sends SIGKILL, an unignorable signal that terminates a process immediately without cleanup
- A well-behaved server catches SIGTERM to finish in-flight requests before shutting down, rather than dying mid-request
Resources
Mastery checklist
- I can find a running process's PID and inspect its resource usage
- I can explain the difference between SIGTERM and SIGKILL
- I can use kill to gracefully or forcefully stop a specific process
- I can identify a resource-hogging process using top or htop