In the C Standard Library, signal processing defines how a program handles various signals while it executes. A signal can report some exceptional behavior within the program (such as division by zero), or a signal can report some asynchronous event outside the program (such as someone striking an interactive attention key on a keyboard).
The C standard defines only 6 signals. They are all defined in header <code><signal.h></code> (<code><csignal></code>):
Additional signals may be specified in the <code><signal.h></code> header by the implementation. For example, Unix and Unix-like operating systems (such as Linux) define more than 15 additional signals; see Unix signal.
A signal can be generated by calling <code>raise()</code> or <code>kill()</code> system calls. <code>raise()</code> sends a signal to the current process, <code>kill()</code> sends a signal to a specific process.
A signal handler is a function which is called by the target environment when the corresponding signal occurs. The target environment suspends execution of the program until the signal handler returns or calls <code>longjmp()</code>.
Signal handlers can be set with <code>signal()</code> or <code>sigaction()</code>. The behavior of <code>signal()</code> has been changed multiple times across history and its use is discouraged. It is only portable when used to set a signal's disposition to SIG_DFL or SIG_IGN. Signal handlers can be specified for all but two signals (SIGKILL and SIGSTOP cannot be caught, blocked or ignored).
If the signal reports an error within the program (and the signal is not asynchronous), the signal handler can terminate by calling <code>abort()</code>, <code>exit()</code>, or <code>longjmp()</code>.
C signals are traditionally used the same way in C++ as in C. However, one can also write wrappers for RAII-style usage.
This can also be done with Boost, using the class <code>boost::asio::signal_set</code>.
C signals can be used with P/Invoke and <code>Mono.Unix.Native.Syscall</code>.
C signals are unofficially usable in Java language, from module <code>jdk.unsupported</code>, with internal JVM classes <code>sun.misc.Signal</code> and interface <code>sun.misc.SignalHandler</code>.
Signals can be used with the signal_hook crate in Rust.