Chapter Contents |
Previous |
Next |
Signal-Handling Functions |
sigprocmask
or
sigblock
before calling
the function to minimize the chance of being interrupted. Then call
sigprocmask
or
sigsetmask
to restore the signal mask when the critical activity is completed.
The call to
sigprocmask
or
sigblock
allows any pending signals to be discovered, so interruption
is possible at this point. However, if no signals are pending, no other interruptions
occur until you reset the mask with
sigprocmask
or
sigsetmask
.
signal
in the
handler for as long as possible. The library postpones processing new asynchronous
signals while a handler is executing, unless the handler calls
sigchk
or
signal
. As soon as you
call
signal
, any pending signals are discovered
and handled. Alternately, use
sigaction
rather than
signal
to define your handlers.
In this case, you do not need to call
signal
again to reinstate your handler, and you can have any signals you
wish blocked automatically during the handler's execution.
sigprocmask
to block signals until the program is ready to process interruptions. When
an interruption can be processed, call
sigsuspend
to wait for the next signal. When the signal occurs, the library
automatically restores the pre-
sigsuspend
signal mask before calling your handler.
sigchk
to discover signals at points in your
code that do not call any functions. Be sure to select points at which all
data structures used by handlers are in a consistent state.
longjmp
function, you may want to use the
blkjmp
function in routines that
can be interrupted to protect some
portions of the routine. This permits the routine to successfully complete
activities that should not be interrupted. Note that if a handler calls
longjmp
while I/O is being performed, the error
flag is set for the file. You must call
clearerr
to continue to use the file, but be aware that information may be
lost from the file.
SIGINT
signal (as well as USS signals such as
SIGTTIN
) can occur at any time while the program is waiting for input
from the terminal.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.