It is perfectly legal for read and write function to return error code -1 and set errno to EINTR. These values indicate that you must repeat read and write calls. This can happen in weird cases related to how signals work on POSX platforms (such as OSX and Linux).
It is perfectly legal for read and write function to return error code -1 and set errno to EINTR. These values indicate that you must repeat read and write calls. This can happen in weird cases related to how signals work on POSX platforms (such as OSX and Linux).
That's why, for example, GNU C library on Linux provides TEMP_FAILURE_RETRY helper macro that will do such loop for you. See here: http://www.gnu.org/software/libc/manual/html_node/Interrupted-Primitives.html No idea if there is similar macro on OSX, but you can easily write it yourself - either loop, or macro. Here's an example how it can look like: http://osxr.org/glibc/source/posix/unistd.h?v=glibc-2.15#1125