Linux System Programming · beginner · ~6 min
Use raise() to signal the calling process from inside its own code.
raise(signo) is shorthand for kill(getpid(), signo) — it sends the named signal to the calling process (or in a threaded program, to the calling thread). Common uses:
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;
}
raise(SIGKILL) thinking you'll catch it inside the same program. SIGKILL is uncatchable; you'll just die.raise(signo) sends a signal to yourself — useful for cleanup-then-re-raise patterns and for testing your own handlers.