Guardian Programmer's Guide

Table Of Contents
Debugging, Trap Handling, and Signal Handling
Guardian Programmer’s Guide 421922-014
25 - 28
Using HP Extensions
Using HP Extensions
The HP signals extensions are provided as migration and convenience tools that allow
native processes to catch signals corresponding to trap conditions in TNS processes.
The signals extensions provide shortcuts to the same basic functions as provided by
the standard signal interfaces.
If you are concerned about conforming to the POSIX.1 standard and application
portability, you should use the standard signals functions. If you are mainly interested
in getting the performance gains of converting from TNS to native processes and want
to focus on handling those signals known as trap conditions in TNS processes, use the
signals extensions.
SIGACTION_INIT_()
The SIGACTION_INIT_() function establishes the initial state of signal handling for a
process. This function is designed to be called once and sets the process signal mask
to unblock all signals. Any signals that are pending when SIGACTION_INIT_() is
called are discarded.
The SIGACTION_INIT_() function installs a signal handler for most signals, including
those corresponding to trap conditions. If a nondeferrable signal is delivered and it is
blocked, the process terminates abnormally.
Signals can be nested, which means that if a signal is delivered while a signal handler
is executing for a different signal, the current signal handler is interrupted and the
signal handler for the most-recently received signal is executed. (Traps cannot be
nested in TNS processes. If a process receives a trap while a trap handler is
executing, the process terminates abnormally.)
If a signal is nondeferrable and the signal handler returns normally, the process
terminates abnormally. In this case, the process should exit using the
siglongjmp() function.
SIGJMP_MASKSET_()
The SIGJMP_MASKSET_() function saves the process signal mask in a jump buffer
that has already been initialized by the sigsetjmp() function. You can save some
overhead processing by not saving the process signal mask in each sigsetjmp()
call and instead calling SIGJMP_MASKSET_() before calling siglongjmp().
SIGACTION_SUPPLANT() and SIGACTION_RESTORE()
The SIGACTION_SUPPLANT_() function saves the current signal-handling state and
allows a subsystem, such as a shared run-time library, to take over signal handling
temporarily. Before exiting the signal handler, the subsystem calls the
SIGACTION_RESTORE_() function to restore the signal-handling state stored by a call
to the SIGACTION_SUPPLANT_() function.