Guardian Programmer's Guide

Table Of Contents
Debugging, Trap Handling, and Signal Handling
Guardian Programmer’s Guide 421922-014
25 - 35
Examples
result = 0; /* 0 means success */
} else {
/* Error path: entered via siglongjmp() called in
localHandler(). */
result = 1;
}
if (SIGACTION_RESTORE_ (&sigSaveBuf))
exit (2);
return result;
}
void globalHandler
( int signo /* signal number */
, siginfo_t *sig_info /* NULL */
, void *sig_context /* pointer to saved process */
)
{
printf ("globalHandler: Signal %d occurred\n", signo);
/* A combination of HIST_* functions and the information
provided in sig_context can be used to format and display
the process execution context when the signal occurred. */
/* Restore the process execution context (including the
process signal mask) saved by sigsetjmp() called from
main() and jump to the location of the sigsetjmp() call
with a return value of 1. */
siglongjmp (sigJmpEnv, 1);
}
main ()
{
printf( "main: start of execution\n" );
if (SIGACTION_INIT_ (globalHandler)) /* install the signal
handler */
{
printf( "main: SIGACTION_INIT failed\n" );
exit (1);
}
if (! sigsetjmp (sigJmpEnv, 1)) {
printf( "main: after sigsetjmp returned 0\n" );
/* Code that could generate a signal that is caught
by globalHandler(). */
if (worker ()) {/* worker() establishes its own */
/* signal handling domain with */