#include <signal.h>
_sig_func signal(int sig, _sig_func handler);
signal() defines how the application responds to the sig signal. The various responses are given by the table below.
| Handler | Response to the Signal |
|---|---|
| SIG_IGN | Ignores the signal |
| SIG_DFL | The default response ( HALT). |
| a function | Calls the function with sig as parameter. |
The signal handling function is defined as:
typedef void (*_sig_func)(int sig);
Raise the signal using the raise() function. Before the handler is called, the response is reset to SIG_DFL.
In the CodeWarrior IDE, there are only two signals: SIGABRT indicates an abnormal program termination, and SIGTERM indicates a normal program termination.
If signal succeeds, it returns the previous response for the signal; otherwise it returns SIG_ERR and sets errno to a positive non-zero value.