
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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)
Here,
signal − The signal number to be invoked.
Here is an example of raise() in C language,
Example
#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); raise(SIGILL); return 0; }
Output
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); raise(SIGILL);
Advertisements