Chapter Contents

Previous

Next
Signal-Handling Functions

Discovering Asynchronous Signals

As mentioned earlier, the library calls handlers for synchronous signals as soon as the signal occurs; however, when an asynchronous signal occurs, the library may not immediately call the handler. There may be a delay because the signal must be discovered by the run-time library. After the signal is discovered, the library calls the handler. There are only three times asynchronous signals are discovered:

You can insert calls to sigchk in your program to decrease the number of statements that are executed before a signal is discovered.

The library limits the times that an asynchronous signal can be discovered to improve your control of signal handling. There are two reasons the SAS/C library delays processing asynchronous signals:

This method of discovering asynchronous signals is a feature of the SAS/C implementation. If you are writing portable code be aware that, on some systems, handlers are always called immediately. In such systems, you must write code carefully to avoid incorrect results if signals are inconveniently timed.


Delaying Discovery of Signals

For many applications, coding a signal handler is complicated by the possibility that a new signal may be generated during the handler's execution (either the same signal or a completely unrelated signal). For POSIX applications, the sigaction function makes it easy to block signals during the execution of a signal handler. For non-POSIX applications, the situation is more complicated, and it may be difficult to block asynchronous signals during the execution of a signal handler. To assist in the writing of reliable code, the SAS/C library suppresses the discovery of new asynchronous signals within a handler. An exception is when the handler calls sigchk , signal , or sigaction , which indicates its readiness to handle new signals. This applies only to asynchronous signals; for example, if a handler divides by 0, the resulting signal cannot be delayed no matter how convenient that might be. Also, any signals that are pending while a handler executes are discovered and processed when the handler returns.

If you are writing portable code be aware that, on some systems, asynchronous signals are discovered even while a handler is executing. On such systems, you must write code carefully to avoid incorrect results if signals are inconveniently timed.


Waiting for Signals

Some programs are interrupt driven; that is, their operation is controlled by signals from external sources (for example, IUCV signals from other VM users). For such programs, it is important to have a waiting period without using CPU resources until a signal is received. The library provides the following functions for this purpose:


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.