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 program

Returns 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

May be interested

  • How to Raise Car Deficiency CounterclaimsHow to Raise Car Deficiency Counterclaims
    after 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 simple ways to 'force' the boss to raise wages
    13 tips to help you hold the key to convince your boss when you want to offer a raise.
  • SUM function in SQL ServerSUM function in SQL Server
    the sql server sum function returns the total value of a column, a data set, or an expression.
  • The ord () function in PythonThe ord () function in Python
    the built-in ord () function in python returns an integer representing the unicode code of the specified character.
  • Notebook computer prices will increaseNotebook computer prices will increase
    the 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 ServerRIGHT function in SQL Server
    the 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 PythonInt () function in Python
    the int () function in python returns an integer object from any number or string.
  • AVG function in SQL ServerAVG function in SQL Server
    the 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 PythonHex () function in Python
    the hex () function is one of python's built-in functions, used to convert an integer into the corresponding hexadecimal form.
  • ABS function in SQL ServerABS function in SQL Server
    this 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.