• Aucun résultat trouvé

Signal Types

Dans le document III CP·6 (Page 158-162)

The various types of signals and their use are explained below.

14-2 Signal Types HA17-00

Signal Handling <signal. h>

SIGABRT Signal Description:

This signal is raised by calling the abort function or by assertion failures which use the assert macro.

Semantics:

The initial handler for this signal is SIG_DFL. If the signal handler returns to its caller, this signal is immediately repeated to the new signal handler which by default will cause program termination. The signal handling function may longjmp to continue execution.

The default handling for this signal is to display a C run-time error message, display the call history at the time of the signal, and stop execution.

SIGALRM Signal Description:

This signal is reserved for future use.

SIGFPE Signal Description:

This signal is raised for division by zero, fixed point overflow, floating point overflow and floating point underflow.

Semantics:

The initial state of this signal is SIG_DFL. If the signal handler returns to its caller, this signal is immediately repeated to the new signal handler which by default will cause program termination (via SIG_DFL handling). The signal handling function may longjmp to continue execution. The default handling for this message is to display a C run-time error message, display the call history at the time of the signal, and stop execution.

If the signal handler for this signal is set to SIG_IGN, the result of the erroneous operation is set to an appropriate value and program execution continues after the point of the error. The "appropriate" value depends upon the fault that occurred. For example, when overflow occurs, the value is set to the largest value that can be represented.

HA17-00 SIGFPE Signal 14-3

Signal Handling <signal. h>

SIGHUP Signal Description:

This signal is raised when the user's terminal is disconnected from the system.

Semantics:

The default handler for this signal is SIG_IGN which causes the disconnect event to be ignored and terminates program execution. If the signal handler returns to its caller, execution continues at the point of the signal. When the SIGHUP signal handler is called, the signal handler for SIGHUP is set to SIG_IGN. This event may be used to complete any database accesses or save the current status of the process.

SIGILL Signal Description:

This signal is raised if the program tries to execute an illegal or nonexistent instruction.

Semantics:

The default handler for this signal is SIG_DFL. If the signal handler returns to its caller, the signal is immediately repeated to the new signal handler which by default will cause program termination via SIG_DFL. The signal handling function may longjmp to continue execution.

The default handling for this signal is to display a C run-time error message, display the call history at the time of the signal, and stop execution.

SIGINT Signal Description:

This signal is raised when a time-sharing user interrupts the program either by using the break key or the escape-B sequence.

Semantics:

The default signal handler is SIG_IGN which causes the command processor to get control when a break event occurs. The signal handler may return to continue execution at the point of interruption, or longjmp to continue execution at a location specified by an earlier setjmp.

After the SIGINT handler is entered, it must immediately establish a new handler for this signal or all subsequent break events will be ignored.

14-4 SIGINT Signal HA17-00

Signal Handling <signal.h>

SIGSEGV Signal Description:

This signal is raised when the program makes an invalid memory access. This includes the following traps: security faults, page faults, programmed faults and various other hardware faults.

Semantics:

The initial handler for this signal is SIG_DFL. If the signal handler returns to its caller, this signal is immediately raised to the new signal handler which by default will cause program termination through the SIG_DFL handler. The signal handling function may longjmp to continue execution.

The default handling for this signal is to display a C run-time error message, display the call history at the time of the signal, and stop execution.

SIGTERM Signal Description:

This signal is raised when the program exits.

Semantics:

The default handler for this signal is SIG_IGN which causes the exit event to be ignored and terminates program execution. If the signal handler returns to its caller, execution continues at the point of the signal.

The exit function and return from the main function do not raise SIGTERM. In addition, termination due to the default signal handler does not raise SIGTERM. All other exits cause SIGTERM to be raised.

When the SIGTERM signal handler is called, the signal handler for SIGTERM is set to SIG_IGN.

This signal may be raised for many reasons including

1. A non-C function executing an M$EXIT, M$ERR or M$XXX monitor call.

2. A monitor service request that had an error which did not specify error handling.

3. Invocation of another program via the M$LDTRC monitor service.

4. An exceptional condition which could not be handled. This will not normally occur.

5. The operator "errored" the user.

6. A resource limit (such as CPU time, or output) was exceeded.

7. The operator "aborted); the user.

HA17-00 SIGTERM Signal 14-5

Signal Handling <signal. h>

The SIGUSRI and SIGUSR2 Signals Description:

These signals are provided for use by C programs. These signals are not raised by the C library under any conditions.

Semantics:

The initial handler for these signals is SIG_DFL. If the signal handler returns to its caller, execution resumes at the point the event was raised. The signal handling function may establish a new handler for the signal and may also longjmp to continue execution.

The default handling for these signals is to display a C run-time error message, display the call history at the time of the signal, and stop execution.

Dans le document III CP·6 (Page 158-162)