Function raise () in C
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
- 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?
May be interested
- How to Raise Car Deficiency Counterclaimsafter the lender sells your repossessed car, it can sue you for the remaining balance of your loan. when you respond to this lawsuit, you can raise both defenses and counterclaims. a defense is any reason why the person filing the lawsuit...
- 13 simple ways to 'force' the boss to raise wages13 tips to help you hold the key to convince your boss when you want to offer a raise.
- SUM function in SQL Serverthe sql server sum function returns the total value of a column, a data set, or an expression.
- The ord () function in Pythonthe built-in ord () function in python returns an integer representing the unicode code of the specified character.
- Notebook computer prices will increasethe first alliance of laptop manufacturers including hewlett-packard (hp), lenovo and acer has just agreed to raise prices for original equipment manufacturers (oems).
- RIGHT function in SQL Serverthe article will explore and guide you how to use the right function in sql server to extract some characters from the right side of a given string.
- Int () function in Pythonthe int () function in python returns an integer object from any number or string.
- AVG function in SQL Serverthe avg function in sql server returns the average value of an expression or average value according to the specified column of the selected row.
- Hex () function in Pythonthe hex () function is one of python's built-in functions, used to convert an integer into the corresponding hexadecimal form.
- ABS function in SQL Serverthis article will show you in detail how to use the abs () handling function in sql server with specific syntax and examples to better visualize and capture functions.