C signal handling: Difference between revisions

Content deleted Content added
Garo (talk | contribs)
zi
Garo (talk | contribs)
Line 23:
A signal handler is a [[Function (computer science)|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 be with <code>signal()</code> or <code>sigaction()</code>. The behavior of <code>signal()</code> has been changed multiple times across history and is now considered deprecated<ref>https://www.cs.drexel.edu/cgi-bin/manServer.pl/signal.2 Signal(2) manpage</ref>. 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>.