Signals are software interrupts which sent to a program to indicate that an important event has occurred. A Signal may be handled by following one of two possible handlers:
User-defined signal handler can override this default action that is called to handle the signal. Signals are handled in different ways. Some signals (such as changing the size of a window) are simply ignored; others (such as an illegal memory access) are handled by terminating the program.
A signal handler function may have any name, but must have return type void and have one int parameter.
Example − we might choose the name sigchld_handler for a signal handler for the SIGCHLD signal (termination of a child process). Then the declaration would be −
void sigchld_handler(int sig);
The parameter passed to signal handler is the number of the signal. A programmer may use the same signal handler function to handle several signals.