Allow a user to interrupt
When the database server processes a large query, you might want to allow the user to interrupt the query request with the Interrupt key (usually CTRL-C).
To do this, you must set up a signal-handler function. The signal-handler function is a user-defined function that the application process calls when it receives a specific signal.
void sigfunc_ptr();
The user-defined signal-handler function can contain the control functions sqlbreak() and sqldone(). If you use any other control function or any SQL statement in the signal handler while the database server is processing, generates an error (-439).
- The setjmp() function saves the current execution environment and establishes a return point for execution after the longjmp() call.
- The longjmp() call is in the signal-handler
function. Use longjmp() in a signal-handling function
only if sqldone() returns
0
(the database server is idle).
See your UNIX™ operating system documentation for more information about the setjmp() and longjmp() system functions.
signal(SIGINT, sigfunc_ptr);
When the application receives the SIGINT signal, it calls the function that sigfunc_ptr indicates. For more information about the signal() system function, see your UNIX operating system documentation.
signal(SIGINT, SIG_DFL);
On a few (mostly older) systems, however, when a signal handler catches a signal, the system reinstates the SIG_DFL action as the handling mechanism. On these systems, it is up to the signal handler to reinstate itself if you want it to handle the same signal the next time the signal is caught. For information about how your system handles signals, check your system documentation.