Skip to content

read and write must check EINTR error case #1

@mmozeiko

Description

@mmozeiko

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions