A signal is a notification sent to a process or thread to indicate that a particular type of event has occurred. Processes can specify the action to be taken when a given signal is raised. This could be calling a given handler function, or ignoring the signal, or performing a default action (usually ignoring the signal or terminating the process). Common uses of signals include:

Some care is needed when writing handler functions because they may be invoked at any point during the execution of a program. They cannot safely access global data unless it is of type sig_atomic_t, or call system functions outside of a limited subset. If a signal handler interrupts a system function that was executing in the foreground then the latter may return early, typically with the error code EINTR.


Further reading