logo

Signals Cheatsheet

A signal is a software interrupt, used to announce asynchronous events to a process.

The first 31 signals are standardized in LINUX; all have names starting with SIG. Some are from POSIX.

# Signal      Default     Comment                              POSIX
  Name        Action

 1 SIGHUP     Terminate   Hang up controlling terminal or      Yes
                          process
 2 SIGINT     Terminate   Interrupt from keyboard, Control-C   Yes
 3 SIGQUIT    Dump        Quit from keyboard, Control-\        Yes
 4 SIGILL     Dump        Illegal instruction                  Yes
 5 SIGTRAP    Dump        Breakpoint for debugging             No
 6 SIGABRT    Dump        Abnormal termination                 Yes
 6 SIGIOT     Dump        Equivalent to SIGABRT                No
 7 SIGBUS     Dump        Bus error                            No
 8 SIGFPE     Dump        Floating-point exception             Yes
 9 SIGKILL    Terminate   Forced-process termination           Yes
10 SIGUSR1    Terminate   Available to processes               Yes
11 SIGSEGV    Dump        Invalid memory reference             Yes
12 SIGUSR2    Terminate   Available to processes               Yes
13 SIGPIPE    Terminate   Write to pipe with no readers        Yes
14 SIGALRM    Terminate   Real-timer clock                     Yes
15 SIGTERM    Terminate   Process termination                  Yes
16 SIGSTKFLT  Terminate   Coprocessor stack error              No
17 SIGCHLD    Ignore      Child process stopped or terminated  Yes
                          or got a signal if traced
18 SIGCONT    Continue    Resume execution, if stopped         Yes
19 SIGSTOP    Stop        Stop process execution, Ctrl-Z       Yes
20 SIGTSTP    Stop        Stop process issued from tty         Yes
21 SIGTTIN    Stop        Background process requires input    Yes
22 SIGTTOU    Stop        Background process requires output   Yes
23 SIGURG     Ignore      Urgent condition on socket           No
24 SIGXCPU    Dump        CPU time limit exceeded              No
25 SIGXFSZ    Dump        File size limit exceeded             No
26 SIGVTALRM  Terminate   Virtual timer clock                  No
27 SIGPROF    Terminate   Profile timer clock                  No
28 SIGWINCH   Ignore      Window resizing                      No
29 SIGIO      Terminate   I/O now possible                     No
29 SIGPOLL    Terminate   Equivalent to SIGIO                  No
30 SIGPWR     Terminate   Power supply failure                 No
31 SIGSYS     Dump        Bad system call                      No
31 SIGUNUSED  Dump        Equivalent to SIGSYS                 No

Grouped by functions

Terminating

  • SIGKILL: terminate at once; cannot catch it or ignore it.
  • SIGTERM: similar to SIGKILL but can be trapped and the process can run its clean-up processes before closing down. The default signal by kill command.
  • SIGINT: interrupt signal, Ctrl-C. This will terminate the program from the terminal.
  • SIGQUIT: Ctrl-D

Stop and continue

  • SIGSTOP tells LINUX to pause a process to be resumed later.
  • SIGCONT tells LINUX to resume the processed paused earlier

Others

  • SIGHUP: connection to a remote host is dropped (SSH).
  • SIGFPE: illegal math operation, like division by zero.
  • SIGSEGV: segment fault.
  • SIGALRM: generated when the timer set by the alarm function goes off.
  • SIGABRT: generated when a process executes the abort function.

Shell Commands

kill is used to send signals to running processes. Default is SIGTERM (i.e. kill -15).

# List all available signals
$ kill -l

# These 3 are equivalent
$ kill -1 PID
$ kill -SIGHUP PID
$ kill -HUP PID

# To really kill a process
$ kill -9 PID

List all Linux signals:

$ trap -l