A signal is an operating-system notification that interrupts an application's usual control flow. Signals provide limited communication between running programs: they carry no message content, but receiving one indicates that something needs attention. Think of a buzzer—it says that something happened without explaining it. section 12.1 section 12.1.1
A signal is not a hardware interrupt. A device can interrupt the CPU to notify the operating system that data is ready; the operating system can then communicate with an application through a signal. Interrupts are handled at the CPU and operating-system level, while applications handle signals. Unlike an interrupt, many signals may be ignored. section 12.0 section 12.1.1
If an application supplies no special handler, the default for most signals is to terminate it. Common examples are:
- SIGINT: requests termination, usually from a person. section 12.5.1
- SIGTERM: requests termination, usually from another program. section 12.5.1
- SIGKILL: terminates immediately; the application cannot recover from it. section 12.5.1
Keep a handler small
A signal handler can set a flag in a global variable, then leave the main loop to check that flag and do the work. Keeping the handler brief reduces the risk of race conditions when handlers run concurrently. In Rust, a mutable static used for the flag requires an unsafe block. section 12.12


