Chapter Contents |
Previous |
Next |
Signal-Handling Functions |
In the normal execution of a program, signals occur
at unpredictable
times. As you write and test a program that handles signals, you may want
to generate signals to ensure that your program handles them correctly. Your
program also may need to generate signals as part of an error-checking routine.
For example, a mathematical function may generate a
SIGFPOFL
signal if it determines that an overflow is certain to occur
during its processing.
The library provides three functions for generating signals:
raise
,
siggen
,
and
kill
.
raise
is an
ISO/ANSI Standard function that raises the signal you pass as the argument.
siggen
is provided
by the SAS/C library; it is not portable. Besides raising the signal you
pass,
siggen
also enables you to define
the value returned by a subsequent call to
siginfo
.
kill
is a POSIX
function used to send a signal to a process. A process can use the
kill
function to send a signal to itself. However,
kill
does not support SAS/C signals, and it can only be used with signals
managed by USS.
If you raise a signal with
raise
or
siggen
the handler is called
immediately, even if the signal is asynchronous, unless it is a blocked signal
managed by USS. Therefore, these functions are not useful for testing signal
blocking.
If you use
raise
or
siggen
to generate a signal with no
special handler defined and the default action is abnormal termination, the
program abnormally terminates. However, this abnormal termination may not
be exactly the same as it would be if the signal had occurred naturally.
User-defined signals (
SIGUSR1
through SIGUSR8
and
SIGASY1 through SIGASY8)
can be generated by using
raise
or
siggen
. Refer to Chapter 12, "User-Added
Signals," in the
SAS/C Library Reference, Volume 2 for another method of raising user-defined signals.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.