Practical UNIX and Internet Security, 3rd Edition
by Simson Garfinkel, Gene Spafford, Alan Schwartz
Signals
Signals are a simple Unix mechanism for controlling processes. A signal is a 5-bit message to a process that requires immediate attention. Each signal has a default action associated with it; for some signals, you can change this default action. Signals are generated by exceptions, which include:
Attempts to use illegal instructions
Certain kinds of mathematical operations
Window resize events
Predefined alarms, including expiration of a timer
The user pressing an interrupt key on a terminal
Another program using the kill( ) or killpg( ) system calls
A program running in the background attempting to read from or write to its controlling terminal
A child process calling exit or terminating abnormally
The system default may be to ignore the signal, to terminate the process receiving the signal (and, optionally, generate a core file), or to suspend the process until it receives a continuation signal. Some signals can be caught—that is, a program can specify a particular function that should be run when the signal is received. As originally designed, Unix supports exactly 31 signals. Some vendors, such as Sun, have extended this set to include more signals. The signals and types are usually listed in the files /usr/include/signal.h and /usr/include/sys/signal.h. Table B-6 contains a summary of the 31 standard signals.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access