Free — no signup required

Signals: Communicating with Processes

2 min read

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:

  1. Default action — the kernel performs a built-in default behavior (often terminating the process).
  2. Custom handler — the process has registered a function to run when this signal arrives (e.g., a web server that reloads config on SIGHUP).
  3. 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.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free