Linux System Programming · beginner · ~8 min
Recognise the five signals you'll encounter every day and know their default action.
You will meet these five constantly. Memorise this table.
| Signal | Number | Sent by | Default action |
|---|---|---|---|
SIGINT |
2 | terminal Ctrl+C | terminate |
SIGTERM |
15 | kill <pid> (default), systemd |
terminate |
SIGKILL |
9 | kill -9 <pid>, kernel last resort |
terminate (uncatchable) |
SIGSEGV |
11 | kernel, on bad memory access | terminate + core dump |
SIGALRM |
14 | alarm(), setitimer() |
terminate |
Bonus to know:
SIGHUP (1) — "your terminal hung up." Daemons traditionally re-read config on this.SIGUSR1 / SIGUSR2 — reserved for your application to use freely.SIGCHLD — a child process changed state. Server processes use this to reap zombies.#include <signal.h>
/* The number-to-name mapping is also exposed at runtime: */
#include <string.h>
#include <stdio.h>
int main(void) {
for (int s = 1; s <= 15; s++)
printf("%2d %s\n", s, strsignal(s));
return 0;
}
SIGINT = Ctrl+C, SIGTERM = polite kill, SIGKILL = unstoppable kill, SIGSEGV = bad pointer, SIGALRM = timer fired. SIGUSR1/SIGUSR2 are yours to use freely.