Software Interrupts
Once a process is running, how do you communicate with it? You can't easily reach into its memory from the outside. The answer is signals — a standardized inter-process notification mechanism built into the Unix kernel.
A signal is a small integer notification delivered asynchronously to a process. "Asynchronously" means the process doesn't have to be waiting for it — the signal interrupts whatever the process is currently doing, similar to how a hardware interrupt interrupts the CPU.
When a process receives a signal, one of three things happens depending on how the process is configured:
- Default action — the kernel performs a built-in default behavior (often terminating the process).
- Custom handler — the process has registered a function to run when this signal arrives (e.g., a web server that reloads config on SIGHUP).
- Ignore — the process has explicitly chosen to discard this signal (only possible for some signals).
Signals are identified by both a name (like SIGTERM) and a number (like 15). The name and number are equivalent — kill -15 and kill -TERM and kill -SIGTERM all do the same thing. There are dozens of numbered signals in total (kill -l lists the full mapping from SIGHUP at 1 upward), but only a handful come up in day-to-day operations: SIGTERM, SIGKILL, SIGHUP, SIGSTOP, and SIGCONT cover almost everything an engineer needs to reason about.