Guardian Programmer's Guide

Table Of Contents
Debugging, Trap Handling, and Signal Handling
Guardian Programmer’s Guide 421922-014
25 - 29
Interoperability Considerations
SIGACTION_SUPPLANT_() sets the process signal mask so that all signals that can
be blocked are blocked from delivery. Signals that can be deferred, which are those
sent to a process by itself and those generated by timers, remain pending until the
process exits the subsystem. Nondeferrable signals, which are generated by the
system to indicate a run-time error in the process, are delivered to the signal handler.
Interoperability Considerations
The following are some considerations you should be aware of when writing code to
handle traps in TNS processes and signals in native processes.
A Guardian process, whether it is a TNS or native process, cannot contain a
mixture of TNS and native procedures and functions. For example, a Guardian
native process cannot call the ARMTRAP procedure, and a Guardian TNS process
cannot call the sigaction() function.
Examples
The first two examples show signal handlers you can use to replace trap handlers that
use the ARMTRAP procedure. The programs perform equivalent function; one is in
pTAL and one is in C.
The third example shows a signal handler that uses all the HP signal extension
functions and history procedures. This example is in C.
Using SIGACTION_INIT_: an Example in pTAL
--You can use this program as a replacement for a trap
--handler that calls the ARMTRAP procedure. This program
--shows how to do the following:
--1. Install a signal handler using the SIGACTION_INIT_
--procedure.
--2. Save the process execution context (including the
--process signal mask) and establish the location to return
--(jump) to from the handler using the SIGSETJMP_ procedure.
--3. Restore the process execution context and perform the
--nonlocal goto (jump) using the SIGLONGJMP_ procedure.
?EXPORT_GLOBALS
?NOLIST, SOURCE $SYSTEM.ZSYSDEFS.ZSYSTAL
?LIST
?NOLIST, SOURCE $SYSTEM.SYSTEM.HTDMSIG
?LIST
?NOLIST, SOURCE $SYSTEM.SYSTEM.HSETJMP
?LIST
?NOLIST, SOURCE $SYSTEM.SYSTEM.EXTDECS0( INITIALIZER,
? DNUMOUT, PROCESS_GETINFO_, FILE_OPEN_, WRITE )
?LIST