In C, raise() asks the program to handle one signal number right now. It is declared in <signal.h> and is useful for testing a handler you installed with signal().
You pass one signal number, such as SIGINT or SIGTERM. On success the call returns 0. On failure it returns a nonzero value. Keep handlers simple, and check the result before assuming the signal was delivered.
Syntax
Pass the signal number you want the current program to handle.
C
raise(SIGINT);
Call
What it does
raise(SIGINT);
Requests that the current program handle SIGINT now.
Include <signal.h>. Pair raise() with a handler installed by signal().
Library declarations
C
int raise(int sig);
Parameters
Parameter
Description
sig
Required. The signal number to raise, such as SIGINT, SIGTERM, or SIGABRT.
Return Value
Return Value
Description
0
Success. The signal was raised for the current program.
nonzero
Failure. The signal could not be raised.
C Examples
Example 1 — Raise SIGINT After Installing a Handler
Install a handler for SIGINT, then raise that signal so the handler runs.