
_START_ARTICLE_
Signal.h
_START_SECTION_
例子
_START_PARAGRAPH_
#include <signal.h>#include <stdio.h>#include <stdlib.h>static void catch_function(int signal) {_NEWLINE_    puts("Interactive attention signal caught.");}int main(void) {_NEWLINE_    if (signal(SIGINT, catch_function) == SIG_ERR) {_NEWLINE_        fputs("An error occurred while setting a signal handler.\n", stderr);_NEWLINE_        return EXIT_FAILURE;_NEWLINE_    }_NEWLINE_    puts("Raising the interactive attention signal.");_NEWLINE_    if (raise(SIGINT) != 0) {_NEWLINE_        fputs("Error raising the signal.\n", stderr);_NEWLINE_        return EXIT_FAILURE;_NEWLINE_    }_NEWLINE_    puts("Exiting.");_NEWLINE_    return 0;}