Oracle7 Administrator's Reference for UNIX

Contents Index Home Previous Next

Using Signal Handlers

This section describes signals Oracle7 uses for two-task communication, and explains how to set up your own signal handlers.

Signals

Signals are installed in a user process when you connect to the database, and are de-installed when you disconnect.

Oracle7 uses the following signals for two-task communications:

SIGCONT is used by the pipe two-task driver to send out-of-band breaks from the user process to the oracle process.
SIGINT is used by all two-task drivers to detect user interrupt requests. SIGINT is not caught by oracle; it is caught by the user process.
SIGPIPE is used by the pipe driver to detect end-of-file on the communications channel. When writing to the pipe, if no reading process exists, a SIGPIPE signal is sent to the writing process. SIGPIPE is caught by both the oracle process and the user process.
SIGCLD is used by the pipe driver. SIGCLD is similar to SIGPIPE, but only applies to user processes, not oracle processes. When an oracle process dies, the UNIX kernel sends a SIGCLD to the user process (wait() is used in the signal handler to see if the server process died). SIGCLD is not caught by oracle; it is caught by the user process.
SIGTERM is used by the pipe driver to signal interrupts from the user side to the oracle process. This occurs when the user presses the interrupt key [Ctrl]+[c]. SIGTERM is not caught by the user process; it is caught by oracle.
SIGIO is used by SQL*Net version 2 protocol adapters to indicate incoming networking events.
SIGURG is used by the SQL*Net version 2 TCP/IP drivers to send out-of-band breaks from the user process to the oracle process.
The listed signals affect Pro*C or other precompiler applications. You can install one signal handler for SIGCLD (or SIGCHLD) and SIGPIPE when connected to oracle. You can have multiple signal handlers for SIGINT as long as the osnsui() routine is called to set this up. You can install as many signal handlers as you want for other signals. If you are not connected to oracle, you can have multiple signal handlers.

Sample Signal Routine

The following example shows how you can set up your own signal routine and the catching routine. For SIGINT, use osnsui() and osncui() to register and delete signal-catching routines.

/* user side interrupt set */
word osnsui( /*_ word *handlp, void (*astp), char * \ ctx, _*/)
/*
** osnsui: Operating System dependent Network Set **User-side
** Interrupt.  Add an interrupt handling procedure **astp. 
** Whenever a user interrupt(such as a ^C) occurs, **call astp
** with argument ctx. Put in *handlp handle for this **handler so that it may be cleared with osncui.
** Note that there may be many handlers; each should 
** be cleared using osncui.  An error code is **returned if an error occurs.
*/
/* user side interrupt clear */
word osncui( /*_ word handle _*/ );
/*
** osncui: Operating System dependent Clear User-side **Interrupt.
** Clear the specified handler. The argument is the **handle obtained from osnsui. An error code is 
** returned if an error occurs.
*/ 

The following is a template for using osnsui() and osncui() in an application program:

/*
** My own user interrupt handler.
*/
void sig_handler()
{
...
}
main(argc, argv)
int arc;
char **argv;
	{
	int handle, err;
	...
	/* set up my user interrupt handler */
	if (err = osnsui(&handle, sig_handler, (char *) \ 0))
		{
		/* if the return value is non-zero, an error \ has occurred
		Do something appropriate here. */
		...
		}
	...
	/* clear my interrupt handler */
	if (err = osncui(handle))
		{
		/* if the return value is non-zero, an error\ has occurred
		Do something appropriate here. */
		...
		}
	...
	}


Contents Index Home Previous Next