Linux System Programming · beginner · ~6 min
Use raise() to signal the calling process from inside its own code.
raise() doesraise(signo) sends the named signal to the program that calls it.
It is shorthand for kill(getpid(), signo). In a multi-threaded program, the signal goes to the calling thread, not the whole process.
SIGINT handler on demand.WIFSIGNALED.#include <signal.h>
#include <stdio.h>
int main(void) {
printf("about to raise SIGUSR1\n");
raise(SIGUSR1); /* default action: terminate */
printf("you won't see this\n");
return 0;
}
SIGKILL in the same program. Calling raise(SIGKILL) and expecting to handle it will not work. SIGKILL cannot be caught or blocked. The process simply terminates.raise(signo) sends a signal to the calling process (or thread).kill(getpid(), signo).SIGKILL is uncatchable, so you cannot handle a raise(SIGKILL).