9. Signals and Timers
9.1 Signal Basics
A signal is a notification that an event has occurred, such as a user typing an interrupt (Ctrl-c, normally), a floating-point exception, or an alarm going off. Usually, a signal is delivered to a process or thread asynchronously and whatever the process or thread is doing is interrupted. The signal might immediately terminate the process, or, by prearrangement, a function designated to catch it might be executed.
9.1.1 Introduction to Signals
To show how a program handles a signal, here’s a simple example of a program that displays a number once every three seconds, but when an interrupt signal occurs, it displays a message and terminates:
The call to sigaction
installed a signal-handling function ...
Get Advanced UNIX Programming, 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.