COHERENT manpages
This page displays the COHERENT manpage for raise() [Let a process send a signal to itself].
List of available manpages
Index
raise() -- General Function (libc) Let a process send a signal to itself #include <signal.h> int raise(signal) int signal; raise() sends signal to the program that is currently being executed. If called from within a signal handler, the processing of this signal may be deferred until the signal handler exits. Example This example sets a signal, raises it itself, then allows the signal to be raised interactivly. Finally, it clears the signal and exits. #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <signal.h> void gotcha(void); void setgotcha(void) { if(signal(SIGINT, gotcha) == SIG_ERR) { printf("Couldn't set signal\n"); abort(); } } void gotcha(void) { char buf[10]; printf("Do you want to quit this program? <y/n> "); fflush(stdout); gets(buf); if(tolower(buf[0]) == 'y') abort(); setgotcha(); } main(void) { char buf[80]; setgotcha(); printf("Set signal; let's pretend we get one.\n"); raise(SIGINT); printf("Returned from signal\n"); printf("Try typing <ctrl-c> to signal <enter> to exit"); fflush(stdout); gets(buf); if(signal(SIGINT, SIG_DFL) == SIG_ERR) { printf("Couldn't lower signal\n"); abort(); } printf("Signal lowered\n"); exit(EXIT_SUCCESS); } See Also libc, signal(), signal.h ANSI Standard, §7.7.2.1