gfinth_c |
Table of contents
Proceduregfinth_c ( GF, interrupt signal handler ) void gfinth_c ( int sigcode ) AbstractRespond to the interrupt signal SIGINT: save an indication that the signal has been received. This routine restores itself as the handler for SIGINT. Required_ReadingGF KeywordsGEOMETRY SEARCH UTILITY Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- sigcode I Interrupt signal ID code. Detailed_Inputsigcode is a signal code. `sigcode' is expected to be the ANSI C parameter SIGINT, which represents the interrupt signal. Detailed_OutputNone. ParametersNone. Exceptions1) 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). FilesNone. ParticularsThis 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. ExamplesThe numerical results shown for this example may differ across platforms. The results depend on the SPICE kernels used as input, the compiler and supporting libraries, and the machine specific arithmetic implementation. 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. Example code begins here. /. Program gfinth_ex1 ./ #include <stdio.h> #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)" ); } printf( "gfinth_c has been established as handler " "for SIGNIT signal.\n" ); /. 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)" ); } printf( "The previous handler has been re-established " "for SIGNIT signal.\n" ); return ( 0 ); } When this program was executed on a Mac/Intel/cc/64-bit platform, the output was: gfinth_c has been established as handler for SIGNIT signal. The previous handler has been re-established for SIGNIT signal. RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) Version-CSPICE Version 1.0.1, 05-AUG-2021 (JDR) Edited the header to comply with NAIF standard. Extended code example to generate outputs and provided example's solution. -CSPICE Version 1.0.0, 25-FEB-2009 (NJB) Index_EntriesGF handle interrupt signal |
Fri Dec 31 18:41:07 2021