Signals is the mechanism by which processes are made aware of events occurring in the system. An important feature of signals is that they are asynchronous, which means that a process may receive a signal at any time during its execution, and must be prepared to respond to the signal at that time. It is even possible for a process to receive a signal while it is executing a system call. Generally, if a system call is interrupted by a signal, then it will return its error value and set errno to the value EINTR. It is then the responsibility of the signaled process to re-try the interrupted call.
Each of the signal types, of which there are currently thirty odd, is given a symbolic name accessed via the <signal.h> header file. The most common signal values and their symbolic names are:
value | symbol | purpose |
1 | SIGHUP | hangup on control terminal |
2 | SIGINT | interrupt from keyboard (Ctrl-c) |
3 | SIGQUIT | quit from keyboard (Ctrl-\) |
8 | SIGFPE | floating point exception (e.g. divide by 0) |
9 | SIGKILL | terminate receiving process |
14 | SIGALRM | end of alarm() system call timeout |
15 | SIGTERM | default kill command signal |
17 | SIGCHLD | child process stopped or terminated |
19 | SIGSTOP | stop execution from keyboard Ctrl-z |
Each signal type has associated with it an action which the kernel will perform on behalf of a process when the process is sent that signal. For most of the signals, the default action is to terminate the receiving process, though, usually, a process can request some alternative action of the system. The various alternatives are: