bitlvl
EN

Linux signal reference

Type a name or number to find a signal. The last column is the exit code a shell reports when a process dies from that signal (128 + number).

 
No.NameDefaultMeaning / causeExit code
1SIGHUPTerminateHangup: the controlling terminal closed. Daemons reuse it to mean “reload configuration”.129
2SIGINTTerminateInterrupt from the keyboard (Ctrl-C).130
3SIGQUITCore dumpQuit from the keyboard (Ctrl-\); dumps core.131
4SIGILLCore dumpIllegal instruction.132
5SIGTRAPCore dumpTrace/breakpoint trap (debuggers).133
6SIGABRTCore dumpAbort signal from abort().134
7SIGBUSCore dumpBus error: bad memory access (alignment, mmap).135
8SIGFPECore dumpFloating-point exception, including integer divide by zero.136
9SIGKILLTerminateKill signal. Cannot be caught, blocked or ignored. Last resort; the process gets no chance to clean up.137
10SIGUSR1TerminateUser-defined signal 1. nginx: reopen logs; dd: print progress; Apache: graceful restart.138
11SIGSEGVCore dumpSegmentation fault: invalid memory reference.139
12SIGUSR2TerminateUser-defined signal 2. nginx: binary upgrade; Gunicorn: re-exec.140
13SIGPIPETerminateWrite to a pipe with no reader. Default kills the process, which is why `yes | head` stops.141
14SIGALRMTerminateTimer signal from alarm().142
15SIGTERMTerminateTermination request. The default for kill, systemd stop and docker stop; programs should catch it and shut down cleanly.143
16SIGSTKFLTTerminateStack fault on coprocessor (unused).144
17SIGCHLDIgnoreChild stopped or terminated.145
18SIGCONTContinueContinue if stopped (fg, kill -CONT).146
19SIGSTOPStopStop the process. Cannot be caught or ignored.147
20SIGTSTPStopStop typed at the terminal (Ctrl-Z).148
21SIGTTINStopBackground process tried to read from the terminal.149
22SIGTTOUStopBackground process tried to write to the terminal.150
23SIGURGIgnoreUrgent data on a socket.151
24SIGXCPUCore dumpCPU time limit exceeded.152
25SIGXFSZCore dumpFile size limit exceeded.153
26SIGVTALRMTerminateVirtual alarm clock.154
27SIGPROFTerminateProfiling timer expired.155
28SIGWINCHIgnoreTerminal window size changed.156
29SIGIOTerminateI/O now possible (asynchronous I/O).157
30SIGPWRTerminatePower failure.158
31SIGSYSCore dumpBad system call: the seccomp filter rejected a syscall (systemd SystemCallFilter=, Docker default profile).159

What a signal is

A signal is a one-word message the kernel delivers to a process: “the terminal closed”, “you touched bad memory”, “please stop”. The process may install a handler for most of them, ignore them, or accept the default action, which is usually to terminate (sometimes with a core dump). Two cannot be caught or ignored: SIGKILL ends the process on the spot and SIGSTOP freezes it.

TERM versus KILL

kill PID sends SIGTERM: a request. A well-written program catches it, finishes the current request, flushes files, closes connections and exits; that is what systemd, Docker and Kubernetes send first. kill -9 sends SIGKILL: the kernel removes the process without running any of its code, so locks stay held, temp files stay, and in-flight writes are lost. Use it only after TERM has been given time (systemd waits TimeoutStopSec, Docker 10 seconds by default) and failed.

Signals as an API

  • SIGHUP: daemons reload their configuration (nginx, sshd, HAProxy with -sf semantics via systemd reload). For a foreground process it means the terminal went away; nohup ignores it.
  • SIGUSR1 / SIGUSR2: program-defined. nginx reopens logs on USR1 and upgrades its binary on USR2; dd prints progress on USR1; Gunicorn and Unicorn use them for graceful restarts.
  • SIGPIPE: writing to a pipe whose reader has exited. Its default action, terminating, is why yes | head ends and why servers must ignore it or handle write errors.
  • SIGCHLD: a child exited; parents reap children with wait(), and a parent that does not leaves zombies.
  • SIGWINCH: the terminal was resized; editors and multiplexers redraw.

Sending signals

kill -TERM 1234        # by name (or kill -15 1234)
kill -s USR1 $(pidof nginx)
pkill -HUP sshd        # by process name
killall -9 runaway     # all processes with that name
systemctl kill -s HUP myservice
docker kill --signal=SIGUSR1 container

Numbers 1–15 are the same on every Unix; above that they differ by architecture (SIGUSR1 is 10 on x86 and 30 on SPARC/MIPS), which is why scripts should use names.

Questions

What is the difference between SIGTERM and SIGKILL?

SIGTERM asks the process to exit and can be handled; SIGKILL ends it immediately and cannot be caught. Always try TERM first; KILL is for processes that are stuck.

What is signal 11 / SIGSEGV?

A segmentation fault: the program read or wrote memory it does not own, usually a null or dangling pointer in C/C++ code or a bug in a native extension. The shell reports exit code 139.

Why did my process exit with 137 when nobody ran kill -9?

The kernel did: the out-of-memory killer sends SIGKILL to the largest process when memory runs out, and container runtimes do the same when a memory limit is hit. Check dmesg or the container’s OOMKilled flag.

Can I ignore SIGINT so Ctrl-C does not stop my script?

Yes: trap "" INT in bash, or signal.signal(SIGINT, SIG_IGN) in Python. Usually it is better to trap it and clean up before exiting, so the user can still stop the script.