3
在一個多線程應用程序中,所有線程都會阻塞所有信號,並且一個線程會以sigwait
的循環執行信號處理。現在我們應該在其他線程使用系統調用如read
和write
後考慮EINTR
?使用sigwait時我們應該關心EINTR嗎?
while (true)
{
num = read(fd, buf, size);
if (num == -1 && errno == EINTR)
continue;
else if (num > 0)
/* handle the buf and read more */
}
另請參閱此評論:http://stackoverflow.com/questions/4959524/when-to-check-for-eintr-and-repeat-the-function-call#comment46931524_4960077 – 2016-02-15 14:33:32