Chapter 10. Signals
Signals were introduced by the first Unix systems to allow interactions between User Mode processes; the kernel also uses them to notify processes of system events. Signals have been around for 30 years with only minor changes.
The first sections of this chapter examine in detail how signals are handled by the Linux kernel, then we discuss the system calls that allow processes to exchange signals.
The Role of Signals
A signal is a very short message that may be sent to a process or a group of processes. The only information given to the process is usually a number identifying the signal; there is no room in standard signals for arguments, a message, or other accompanying information.
A set of macros whose names start with the prefix
SIG
is used to identify signals; we have
already made a few references to them in previous chapters. For
instance, the SIGCHLD
macro was mentioned in
Section 3.4.1. This macro, which expands into
the value 17 in Linux, yields the identifier of the signal that is
sent to a parent process when a child stops or terminates. The
SIGSEGV
macro, which expands into the value 11,
was mentioned in Section 8.4 ; it yields
the identifier of the signal that is sent to a process when it makes
an invalid memory reference.
Signals serve two main purposes:
To make a process aware that a specific event has occurred
To force a process to execute a signal handler function included in its code
Of course, the two purposes are not mutually exclusive, since ...
Get Understanding the Linux Kernel, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.