Program Signal Handling
Use the signal
function to specify how to handle signals. For each signal, you
can specify one of the types of handlers listed below. The signal
constants are defined in the signal.h header file.
- SIG_DFL
Specifies the default action. This is the initial setting
for all signals. For most signals, the default action is
to terminate the process with an error message. If you
build your program with the /Tx+ compiler
option , the default action can be accompanied by a
dump of the machine state. The dump is sent to file
handle 2, which is usually associated with stderr. Call
the
_set_crt_msg_handle function to change the
destination of the machine-state dump and other messages.
- SIG_IGN
Ignores the condition and tries to continue running the
program. If you specify SIG_IGN for a signal that cannot
be ignored, such as division by zero, the VisualAge for
C++ library treats the signal as if SIG_DFL was
specified.
- Your own signal handler function
Registers the function you specify. This can be a
function you have written. When the signal is reported
and your function is called, signal handling is reset to
SIG_DFL to prevent recursion should the same signal be
reported from your function.
To reset default handling for a signal, call the signal in a
statement similar to the following. Specify the signal name in
the first argument of signal.
signal(sig, SIG_DFL);

Signals and Exceptions
Signal and Exception Handling

Write or Register a Signal Handler

Default Signal Handlers