antirez/redis — pull request #2102 by jamel (2014-10-25 20:43:35+00:00)
Title: Check for EAGAIN and EINTR after read syscall

In accordance with the man page of read(2) syscall:
http://man7.org/linux/man-pages/man2/read.2.html

when it returns -1 there are three possible issues:

1. errno == EINTR. This indicates that a signal was received before any
bytes were read and read() can be reissued.
2. errno == EAGAIN. File descriptor from which we read is marked as
nonblocking and the read() would block because no data is currently
available.
3. Otherwise there is a more serious error. Simply reissuing the read is
unlikely to succeed.

According with the man page of signals(7):

http://man7.org/linux/man-pages/man7/signal.7.html

there are two possible solutions to properly handle interuptions of syscalls:

1. Provide behavior compatible with BSD signal semantics by using
SA_RESTART flag with signal handlers.
2. Check errno each time after syscall returns error and reissue it if needed.