7.2 Disposition of a signal
The signal function (prototype in <signal.h>) lets a program specify the disposition of a signal. The prototype of signal
is as follows:
sighandler_t signal(int signum, sighandler_t handler);
The signal function takes two parameters. signum is the signal number. handler has three options:
- SIG_IGN: this is a constant defined to indicate the signal is to be ignored. Note that some signals cannot be
ignored.
- SIG_DFL: this is a constant defined to indicate the signal is to be handled in the default manner.
- address of a handler: this option specifies that the signal is to be “caught” by the handler specified. However,
this option is not recommended as per the man page of signal itself.
The signal function returns the previous option. This makes it possible to save a signal disposition, change it, then
restore the original signal disposition when it is appropriate.