cpp/utility/program/signal

Sets the handler for signal to the handler  points to. The signal handler can be set so that default handling will occur, signal is ignored, or a user-defined function is called.

When signal handler is set to a function and a signal occurs, it is implementation defined whether will be executed immediately before the start of signal handler. Also, the implementation can prevent some implementation-defined set of signals from occurring while the signal handler runs.

For some of the signals, the implementation may call at the startup of the program. For the rest, the implementation must call.

(Note: POSIX introduced to standardize these implementation-defined behaviors)

Return value
Previous signal handler on success or sig_err on failure (setting a signal handler can be disabled on some implementations).

Signal handler
The following limitations are imposed on the user-defined function that is installed as a signal handler.

If the user defined function returns when handling sigfpe, sigill, sigsegv or any other implementation-defined signal specifying a computational exception, the behavior is undefined.

If the signal handler is called as a result of std or std (synchronous signal), the behavior is undefined if the signal handler calls std.