The SAS/C signal-handling implementation offers many extensions that make it easier to use than a completely standard implementation. However, if you use these extensions, your programs are not portable. Keep in mind these considerations when writing a program that you intend to be portable:
SIGTERM. Note that different implementations of C do not always generate signals for the same reasons. For example, in some implementations, a floating-point underflow may set the result to 0 instead of raising
SIGFPE. The only signals that are guaranteed are those generated by calls to
signalare in the ANSI Standard library. The remaining functions, which may be convenient, cannot be used in a portable program. The functions
sigsuspendare portable to other systems that implement the POSIX 1003.1 standard.
signalagain immediately after entering the handler. This call minimizes the chance that the same signal will occur again and cause program termination.
If you are writing programs to run only with the SAS/C library, you can delay
until the end of the handler,
because new asynchronous signals are not discovered until the handler returns,
is called. If you call
at the beginning of the handler to reinstate
signal handling, refer to the third list item.
longjmpin a signal handler. Also, in implementations other than SAS/C, library data may be left in an inconsistent state if
longjmpis called in a handler after a library function is interrupted. This can cause unpredictable results if the same function or a related function is called again. (The SAS/C library uses the
blkjmpfunction in many cases to intercept
longjmpfrom a handler, so the problem should not arise in a SAS/C program, except for signals associated with ABEND.)
signalfrom a handler is dangerous. This is especially true of memory allocation and I/O functions.
static volatile sig_atomic_tvariable defined outside the handler. (The SAS/C library defines
Then, in an appropriate area of
the main code, test
variable set by the handler
to determine whether a signal has occurred. Even using this process, incorrect
results can occur if the compiler optimizes references to the variable. Making
may help prevent
signumargument even if it is not used in the handler. Here is an example:
Top of Page
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.