The signal is used for a one-step event. When a signal occurs, the program performs the appropriate operation according to the programmed program.
There are two ways in which processes can be used for signal processing:
1, capture signal: When a signal to send a process, the process will call this signal registration signal processing function, to complete the corresponding operation. Each signaling system typically has a corresponding default handler function (typically the terminating process). So you can set the signal as the default handler function.
2, ignore the signal. When the signal is sent, the process ignores the signal.
Note: There are two signals that cannot be captured and ignored by Sigkill and Sigstop. They are provided to the administrator and can be set at any time to terminate a process.
Signal processing requirements: Sometimes the process needs to respond to a signal immediately when the user is programming. For some real-time processes, when it is executed it is unwilling to be interrupted, and this is the need to suspend the received signal.
Use of the signal:
One of the most common applications of a signal is that the notification process ends when an error occurs. For many errors, such as bus errors, floating-point errors, calling memory errors, etc., there is a corresponding signal notification process.
Besides, there are other uses for the signal. If you run a large scientific computing program, if you use printf in an infinite loop to display the running state, it is bound to cause a decline in operational efficiency. So through the signal, artificial to the process to send messages to view the running state, greatly improve the operational efficiency.
View a full set of articles: Http://www.bianceng.cn/Programming/C/201212/34807.htm