pselect如何解决竞争情况

李灼辉 发布于 2013/05/25 16:25
阅读 86
收藏 0
The reason that pselect() is needed is that if one wants to wait for either a signal or for a file descriptor to become ready, then an atomic test is needed to prevent race conditions. (Suppose the signal handler sets a global flag and returns. Then a test of this global flag followed by a call of select() could hang indefinitely if the sig‐ nal arrived just after the test but just before the call. By contrast, pselect() allows one to first block signals, handle the signals that have come in, then call pselect() with the desired sigmask, avoiding the race.)
我在pselect的manpage上见到这样上面这一段话,我想问的是上面所说的竞争情况是如何发生的,换句话说,不理解上面怎么就发生了竞争情况。谢谢!
加载中
返回顶部
顶部