C signal handling: Difference between revisions

Content deleted Content added
Standard signals: rm unnecessary bold - see MOS:NOBOLD
FrescoBot (talk | contribs)
m Bot: link syntax and minor changes
 
(One intermediate revision by one other user not shown)
Line 11:
 
*<code>SIGABRT</code> – "abort", abnormal termination.
*<code>SIGFPE</code> – [[Floating point exception|floating point exception]].
*<code>SIGILL</code> – "illegal", invalid instruction.
*<code>SIGINT</code> – "interrupt", interactive attention request sent to the program.
*<code>SIGSEGV</code> – "[[segmentation violation|segmentation violation]]", invalid memory access.
*<code>SIGTERM</code> – "terminate", termination request sent to the program.
 
Line 54:
#include <stdio.h>
#include <stdlib.h>
 
volatile sig_atomic_t status = 0;
 
static void catch_function(int signo) {
status = signo;
puts("Interactive attention signal caught.");
}
 
Line 66 ⟶ 68:
}
puts("Raising the interactive attention signal.");
if (raise(SIGINT) != 0) {
fputs("Error raising the signal.\n", stderr);
return EXIT_FAILURE;
}
if (status == SIGINT) puts("Interactive attention signal caught.");
puts("Exiting.");
return EXIT_SUCCESS;