As a communication method of asynchronous process, signal is convenient and practical in practical application. However, it should also be noted that there is a potential danger in using the signal. Here is a brief introduction to several specific situations that may cause errors, and we hope to pay special attention to the actual signal processing.
Some system calls may be modified when a signal processing function is registered. Usually, they should be unaffected by the signal, but because a signal processing function is registered, the system may think it needs to interrupt the original system call when a signal arrives. When this occurs, the original system call is terminated, the call failure value is returned, and the errno is set to Eintr. There are times, of course, when you really want the system to handle this, in other cases, however, this is not desirable because the error code returned may cause the subsequent process to fail in the desired direction and may even result in the loss of the data because the call succeeds due to the failure to return the error in subsequent runs. Therefore, it is recommended that you use function sigaction to set the SA_RESTART flag to prevent this from happening.
Alternatively, there may be another signal generated when you perform a signal processing function that is set by the user. This may cause the first call to be interrupted and a second signal-processing function call. The execution of the first call is resumed when the second call is completed. This will affect the operation of the function, especially for programs that use static variables. In this case, you can call the function Sigaction set Sa_nodefer to block the second signal.
In addition, in a busy system, operations that involve system time may be different from the expected effect. For example, the function pause is called after the alarm call, and it is hoped that the pause state will end when the alarm set alarm occurs. However, because the system is too busy to allow this process to be divided into too little time, when the alarm occurs, function pause has not been called, then when the function pause is called will likely cause the process is forever suspended.
-----(above from "Linux Environment C Programming Guide")
View a full set of articles: Http://www.bianceng.cn/Programming/C/201212/34807.htm