raise() function in C/C++

The function raise() is used to send the signals to the program. The predefined function signal() is invoked. It is implemented to check whether it will ignore the signal or invoke the signal handler. This is declared in “signal.h” header file. It returns zero,if successful otherwise, non-zero value.

Here is the syntax of raise() in C language,

int raise(int signal)


signal − The signal number to be invoked.

Here is an example of raise() in C language,


 Live Demo

#include <signal.h>
#include <stdio.h>
void handler(int sig) {
   printf("Signal received : %d\n", sig);
int main() {
   signal(SIGILL, handler);
   printf("Sending signal : %d\n", SIGILL);
   return 0;


Sending signal : 4
Signal received : 4

In the above program, a function handler is defined before the main() function and in the main function, signal() is invoked and SIGILL ( Signal Illegal Instruction ) is sent and received.

signal(SIGILL, handler);
printf("Sending signal : %d\n", SIGILL);

Updated on: 26-Jun-2020


Kickstart Your Career

Get certified by completing the course

Get Started