|
|
#include <signal.h>void (*signal(int signal, void (*func)(int))) (int);
The signal( ) function registers the function pointed to by func as a handler for the signal specified by signal. That is, the function pointed to by func will be called when signal is received by your program. It uses the header <signal.h>, or <csignal> in a C++ program.
The value of func can be the address of a signal handler function or one of the following macros, defined in <signal.h>:
Macro | Meaning |
---|---|
SIG_DFL | Use default signal handling |
SIG_IGN | Ignore the signal |
If a function address is used, the specified handler will be executed when its signal is received. Check your compiler’s documentation for additional details.
On success, signal( ) returns the address of the previously defined function for the specified signal. On error, SIG_ERR (defined in <signal.h>) is returned.
A related function is raise( ).
|
|