5

In a multi threaded application all threads block all signals and a single thread does the signal handling in a loop with sigwait. Now should we consider EINTR after using system calls like read and write in other threads?

while (true)
{
    num = read(fd, buf, size);
    if (num == -1 && errno == EINTR)
        continue;
    else if (num > 0)
        /* handle the buf and read more */
}
Majid Azimi
  • 5,575
  • 13
  • 64
  • 113

1 Answers1

4

EINTR is only returned if the system call was interrupted by a signal handler. If all signals are blocked in the signal mask of the thread that's making the system call, then this can't happen.

caf
  • 233,326
  • 40
  • 323
  • 462
  • See also this comment: http://stackoverflow.com/questions/4959524/when-to-check-for-eintr-and-repeat-the-function-call#comment46931524_4960077 – Niklas Peter Feb 15 '16 at 14:33