9. signal.h
A method that signal the signal generated by the handler when it is run.
Macro:
Sig_dfl
Sig_err
Sig_ign
Sigabrt
Sigfpe
Sigill
SIGINT
SIGSEGV
Sigterm
Function:
Signal ();
Raise ();
Variable:
typedef sig_atomic_t
9.1. Variables and definitions
The type sig_atomic_t is an int, as a variable in the handler of the signal function. Sig_ macros are used in signal functions to define signal functions.
SIG_DFL default handler.
Sig_err indicates an error signal.
Sig_ign ignore the signal.
The SIG macro represents a signal number in the following cases.
SIGABRT terminated abnormally (generated by the Abort function).
SIGFPE floating-point error (generated by 0 in addition to running, unreasonable operation).
Sigill Illegal operation (instruction).
SIGINT Interactive signals (such as our familiar ctrl-c).
SIGSEGV Illegal store access (segment error, memory error).
Sigterm terminate the request.
9.2. Signal
Statement:
void (*signal (int sig, Void (*FUNC) (int))) (int);
This function manages how a signal should be manipulated. The sig represents a signal number that is compatible with the SIG macro. The Func function is invoked when the signal is generated. If the function is SIG_DFL, the default handler is invoked. If the Func is sig_ign, the signal is ignored. If Func points to a function, the function is invoked when a signal is detected and the default handler is executed. The function must carry an int parameter to represent the signal number. The function may be return,abort,exit, or longjmp terminated. When the function terminates, the program continues to execute from the interrupt (unless it is the result undefined signal sigfpe).
If the signal call succeeds, a pointer to the handler of the previously specified signal type is returned. If the signal call fails, the SIG_ERR is returned and the errno is set to a reasonable value.