void gfinth_c ( int sigcode )
Respond to the interrupt signal SIGINT: save an indication
that the signal has been received. This routine restores
itself as the handler for SIGINT.
GF
GEOMETRY
SEARCH
UTILITY
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
sigcode I Interrupt signal ID code.
sigcode is a signal code. `sigcode' is expected to be the
ANSI C parameter SIGINT, which represents the
interrupt signal.
None.
None.
1) If `sigcode' is not SIGINT, the error SPICE(INVALIDSIGNAL)
is signaled (in the SPICE error handling sense).
2) If the call to the ANSI C function `signal' made
by this routine fails, the error SPICE(SIGNALFAILED)
is signaled (via SPICE error handling).
None.
This interrupt handler should be used by routines that
participate in GF interrupt handling. Such routines should
call the ANSI C library routine `signal' with the ANSI C
macro SIGINT and this routine as the input arguments.
When this routine executes, it re-establishes itself as the
handler for the interrupt signal SIGINT. Code that uses
CSPICE interrupt handling must restore the previous
handler before returning.
Once this routine is established as the handler for the
interrupt signal SIGINT, the GF "bail out" test routine
gfbail_c will return SPICETRUE until the interrupt status
is cleared via a call to gfclrh_c.
1) Make this routine the GF signal handler, then restore
the previous handler. This example serves only to
demonstrate the use of signal; the example code
performs no useful function.
#include <signal.h>
#include "SpiceUsr.h"
int main()
{
/.
Prototypes
./
static void ( * previousHandler )(int);
static void ( * handlerPtr )(int);
/.
Make gfinth_c the handler for the SIGINT signal.
./
previousHandler = signal ( SIGINT, gfinth_c );
if ( previousHandler == SIG_ERR )
{
setmsg_c ( "Attempt to establish gfinth_c as the "
"handler for the SIGINT signal failed." );
sigerr_c ( "SPICE(SIGNALFAILED)" );
}
/.
Restore the previous handler.
./
handlerPtr = signal ( SIGINT, previousHandler );
if ( handlerPtr == SIG_ERR )
{
setmsg_c ( "Attempt to re-establish the previous "
"handler for the SIGINT signal failed." );
sigerr_c ( "SPICE(SIGNALFAILED)" );
}
return ( 0 );
}
None.
None.
N.J. Bachman (JPL)
-CSPICE Version 1.0.0, 25-FEB-2009 (NJB)
GF handle interrupt signal
Link to routine gfinth_c source file gfinth_c.c
|