Function raise () in C
Function int raise (int sig) in Library C creates sig signal. The sig parameter is compatible with the SIG macro.
Function int raise (int sig) in Library C creates sig signal. The sig parameter is compatible with the SIG macro.
Declare the function raise () in C
Below is the declaration for signal () function in C:
int raise ( int sig )
Parameters
sig - This is the signal number to gửi. Following are few important Standard signal constantstrong Library C:
macrosignalSIGABRT (Signal Abort) Abnormal termination, such as initialized by abort function SIGFPE (Signal Floating-Point Exception) Operation related to arithmetic is not correct, such as dividing by zero or overflow (overflow) SIGILL (Signal Illegal Instruction) An invalid SIGINT (Signal Interrupt) instruction instruction Interrupt signal, usually created by the user application SIGSEGV (Signal Segmentation Violation) Invalid access to storage, when a program try to read or write outside the memory allocated to it SIGTERM (Signal Terminate) The end request is sent to the programReturns the value
This function returns 0 if successful. If not, the function returns a value other than 0.
For example
The following C program illustrates the usage of the signal () function in C:
#include #include #include void signal_catchfunc ( int ); int main () { int ret ; ret = signal ( SIGINT , signal_catchfunc ); if ( ret == SIG_ERR ) { printf ( "Error: khong the thiet lap signal handler.n" ); exit ( 0 ); } printf ( "Chuan bi tao mot tin hieun" ); ret = raise ( SIGINT ); if ( ret != 0 ) { printf ( "Error: khong the tao tin hieu SIGINT.n" ); exit ( 0 ); } printf ( "Dang thoat .n" ); return ( 0 ); } void signal_catchfunc ( int signal ) { printf ( "!!! Tin hieu da duoc bat !!!n" ); }
Compiling and running the above C program will result:
Chuan bi tao mot tin hieu !!! Tin hieu da duoc bat !!! Dang thoat .
According to Tutorialspoint
Previous post: signal.h in C
Next lesson: Function signal () in C
5 ★ | 1 Vote
You should read it
- Function signal () in C
- Signal Processing (Signal Handling) in C ++
- signal.h in C
- How to delete Signal account
- What is a modem? Functions of Modem
- How to use stickers / stickers expressing emotions in Signal
- What color is the turn signal light? It's easy to think but 90% of people answer wrong
- How to enable Registration Lock in Signal
- The exit () function in C
- Signal and Telegram: Where is the privacy-focused cross-platform chat app better?
- How to fix 'Input Signal Out of Range' error on Windows
- How strong is the wireless signal in your Wi-Fi network?
Maybe you are interested
'Silent' Town: No Wifi, No Mobile Signals for Over 60 Years
Google recommends turning off 2G signals to prevent fraud
AI can analyze radiation from HDMI cable signals to hack data on the screen
Fixed an issue where there was no video signal when the TV was connected via HDMI
Humanoid robot drives itself and obeys traffic signals
The Voyager 1 spacecraft sent signals to Earth for the first time in 5 months