Signal Handling:

Signal handling basically defines he signals that are to be handled while the execution of a program. Signal handling is used in C++ standard library. There are different types of errors while writing a C++ program.

These errors include syntax errors, logical errors, and run time errors. Signal handling is used to handle or report these errors such as division by zero that causes a runtime error.

 

Implementing the signal

A signal can be called or generated using raise () function. A signal can also be called using another function that is kill ().

 

The raise function

When the raise function is called, it sends the signal to the process that is currently being executed.

 

The kill function

When the kill function is called, it sends a signal to the process that is specified by the user.

 

Signal Handler

Signal handler is basically a function that is called when a corresponding signal occurs. It is a function that is actually defined to handle the signal.

In C++ standard library, there are six important standard signals that are used to handle signals, for example SIGABRT is used to terminate a signal, SIGILL occurs when an illegal instruction is used in a program, SIGFPE occurs when a stack overflow occurs such division by zero, SIGINT stands for signal interrupt, it generated by the user, SIGSEGV stands for segmentation violation it occurs when an outside storage is used, SIGTERM stands for signal terminate. These standard signals are also called macro constants.