Should we care about EINTR when using sigwait?

c, multithreading, signals

Solution

`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.

Problem

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 */ } ```

Original source

Related problems