Appendix D: Signal Reference

Signal Table (x86-64 Linux)

+--------+---------+---------+----------------------------------------------+
| Number | Name    | Default | Common Cause                                 |
+--------+---------+---------+----------------------------------------------+
|   1    | SIGHUP  | Term    | Terminal closed, or controlling process died  |
|   2    | SIGINT  | Term    | Ctrl+C from terminal                         |
|   3    | SIGQUIT | Core    | Ctrl+\ from terminal (quit + core dump)      |
|   4    | SIGILL  | Core    | Illegal instruction (corrupt code, bad jump) |
|   5    | SIGTRAP | Core    | Breakpoint hit (used by debuggers, int3)     |
|   6    | SIGABRT | Core    | abort() called (failed assert, double free)  |
|   7    | SIGBUS  | Core    | Bus error: misaligned access, bad mmap       |
|   8    | SIGFPE  | Core    | Arithmetic error: divide by zero, overflow   |
|   9    | SIGKILL | Term    | Unconditional kill (CANNOT be caught)        |
|  10    | SIGUSR1 | Term    | User-defined signal 1                        |
|  11    | SIGSEGV | Core    | Segmentation fault: invalid memory access    |
|  12    | SIGUSR2 | Term    | User-defined signal 2                        |
|  13    | SIGPIPE | Term    | Write to pipe/socket with no reader          |
|  14    | SIGALRM | Term    | Timer from alarm() expired                   |
|  15    | SIGTERM | Term    | Polite termination request (what kill sends) |
|  17    | SIGCHLD | Ignore  | Child process stopped or terminated          |
|  18    | SIGCONT | Cont    | Resume stopped process (sent by fg, kill -18)|
|  19    | SIGSTOP | Stop    | Unconditional stop (CANNOT be caught)        |
|  20    | SIGTSTP | Stop    | Ctrl+Z from terminal                         |
+--------+---------+---------+----------------------------------------------+

Default Actions

Term  = Terminate the process
Core  = Terminate + generate core dump (if enabled: ulimit -c unlimited)
Stop  = Suspend the process (can resume with SIGCONT)
Cont  = Resume a stopped process
Ignore = Do nothing by default

Uncatchable Signals

Only two signals cannot be caught, blocked, or ignored:

  • SIGKILL (9): Always terminates. The process gets no chance to clean up.
  • SIGSTOP (19): Always suspends. The process cannot prevent it.

Every other signal can be caught with signal() or sigaction().

Sending Signals

kill -SIGTERM 1234       # send SIGTERM to PID 1234
kill -9 1234             # send SIGKILL (cannot be caught)
kill -STOP 1234          # suspend process
kill -CONT 1234          # resume process
Ctrl+C                   # sends SIGINT to foreground process
Ctrl+Z                   # sends SIGTSTP to foreground process
Ctrl+\                   # sends SIGQUIT (core dump)

The Signals You Will See Most

If your program crashes, check the signal:

  • SIGSEGV (11): You accessed memory you should not have. See Chapter 18.
  • SIGABRT (6): Something called abort() — often a failed assertion or detected heap corruption.
  • SIGFPE (8): Division by zero or integer overflow trap.
  • SIGPIPE (13): You wrote to a closed pipe. Common in shell pipelines and network code.
  • SIGBUS (7): Misaligned memory access, or mmap beyond file size.