9.1. The Role of Signals

A signal is a very short message that may be sent to a process or to a group of processes. The only information given to the process is usually the 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 has been mentioned in Section 3.3.1 in Chapter 3. This macro, which expands into the value 17 in Linux, yields the identifier of the signal that is sent to a parent process when some child stops or terminates. The SIGSEGV macro, which expands into the value 11, has been mentioned in Section 7.4 in Chapter 7 : 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 often a process must react to some event by executing a specific routine.

Table 9-1 lists the first 31 signals handled by Linux 2.2 for the Intel 80x86 architecture (some signal numbers such as SIGCHLD or SIGSTOP are architecture-dependent; furthermore, some signals are defined only for specific architectures). Besides the signals described in this table, the POSIX ...

Get Understanding the Linux Kernel 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.