Add Book to My BookshelfPurchase This Book Online

Chapter 10 - Signals

UNIX Systems Programming for SVR4
David A. Curry
 Copyright © 1996 O'Reilly & Associates, Inc.

Chapter 10: Signals
Overview
Signals are software interrupts. They provide asynchronous notification to a process that something has happened—either an unexpected problem has arisen, or a user (or another process) has requested that the process do something outside of its normal operational functions. Some signals, such as “illegal instruction” or “arithmetic exception,” have a direct relationship to the computer hardware. Other signals, such as “window size change” or “CPU time limit exceeded,” are purely software-oriented. Most of the signals provided by the UNIX operating system cause a process to exit when they are received, unless the process takes steps to handle that signal. Some of the signals also cause the process' memory image to be placed on disk in the file core, allowing debuggers to examine the image in order to determine what caused the problem.
UNIX signal handling used to be both simple to do and simple to explain—there was only one way to do things, and everyone followed it. However, as the need for more sophisticated signal handling increased, other ways of doing things evolved. As each new way was implemented, explaining things got harder—not only was there more to explain about how things worked, but it also became necessary to explain which methods were used for which situations. This problem has reached a peak in SVR4, which provides four different methods for handling signals: the original basic mechanism introduced in Version 7, the somewhat more robust mechanism introduced in SVR3, a compatibility library implementation of the Berkeley mechanism used by many vendors' operating systems, and, new to SVR4, the POSIX mechanism.
In this chapter, we will discuss all four of these signal handling mechanisms. Fortunately, the uses of the four mechanisms fairly closely parallel their complexity. That is, basic signal handling is easily performed using the easy-to-understand mechanisms; the more complicated mechanisms are only needed for more advanced functionality. Thus, we begin by introducing the basic concepts of signal handling that are common to all four mechanisms. We then examine basic signal handling as it was originally implemented in Version 7. Following this, we consider reliable signals, one of the most important additions to signal handling procedures. We next examine one of the more common uses for signals, implementing timeouts. After this, we move into the area of advanced signal handling, by looking at the sophisticated POSIX signal mechanism. We conclude with a detailed look at the Berkeley signal mechanism, upon which the POSIX mechanism is based. It is in this section that we present information on porting between the Berkeley mechanism and the others.

Previous SectionNext Section
Books24x7.com, Inc © 2000 –  Feedback