This seriesArticlePrepared by muge0913, reprinted please indicate the source Thank you: http://blog.csdn.net/muge0913/article/details/7322844
Signals are used for one-step events. When a signal occurs,ProgramThe operation will be performed according to the configured program.
Processes generally process signals in two ways:
1,Capture Signal: When a signal sends a process, the process calls the signal processing function registered for this signal to complete the corresponding operations. Corresponding to each signal system, a corresponding default processing function is generally used to terminate a process ). Therefore, you can set the signal as the default processing function.
2,Ignore Signal. When the signal is sent, the process ignores the signal.
Note: There are two signals: sigkill and sigstop, which cannot be captured or ignored. They are provided to administrators and can be set to terminate a process at any time..
Requirement on Signal Processing: Sometimes the process needs to respond immediately to a signal During User Programming. For some real-time processes, they are unwilling to be interrupted during execution. This means they need to suspend the received signal.
Signal usage:
One of the most common applications of signals is to notify the process to end when an error occurs. For many errors, such as bus errors, floating point errors, and calling memory errors, the process is notified accordingly.
In addition, the signal has other functions. For example, running a large scientific computing program, if printf is used in an infinite loop to display the running status, it will inevitably lead to a decrease in the running efficiency. Therefore, by sending messages manually to processes to view the running status, the running efficiency is greatly improved.