- 论坛徽章:
- 0
|
原帖由 coconutmm 于 2007-5-18 20:08 发表
其实,我的意思是说,因为select和上一条语句之间,存在时间窗,也学信号就是在这个时间内发生,对于select存在的信号可能已经丢失了
当然会了, APUE上描述的还是很明确, 我们只能通过sigsuspend解决pause这个问题, 但是select确无法解决. ^^
APUE 10.16:
We test each of the global flags before calling select and again if select returns an interrupted system call error. The problem occurs if either signal is caught between the first two if statements and the subsequent call to select. Signals occurring in here are lost, as indicated by the code comment. The signal handlers are called, and they set the appropriate global variable, but the select never returns (unless some data is ready to be read).
What we would like to be able to do is the following sequence of steps, in order.
Block SIGINT and SIGALRM.
Test the two global variables to see whether either signal has occurred and, if so, handle the condition.
Call select (or any other system function, such as read) and unblock the two signals, as an atomic operation.
The sigsuspend function helps us only if step 3 is a pause operation. |
|