[pacman-dev] [PATCH] Looping for EINTR on close() is wrong on Linux

Dan McGee dpmcgee at gmail.com
Wed Jul 3 18:05:45 EDT 2013


On Wed, Jul 3, 2013 at 4:38 PM, Simon Gomizelj <simongmzlj at gmail.com> wrote:
> That said, the loop is possibly a source of bugs for another reason,
> apparently its possible for the fd to have been closed and reused by the
> time EINTR fires, causing an unrelated fd to be closed.
>
>> As discussed in this thread, many POSIX implementations, including
>> Linux, will release the file descriptor immediately, and so if close()
>> fails with EINTR, it is possible that the file descriptor has already
>> been reclaimed and in use by some other component. Retrying the close
>> call, therefore, might close some other component's descriptor.
>
>  - https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain
>  - http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html

Given that we are single-threaded, I don't see how this is possible.

-Dan


More information about the pacman-dev mailing list