[pacman-dev] [PATCH] do not check error from close(2)

Sergio Correia lists at uece.net
Thu Jul 4 09:11:20 EDT 2013


On Wed, Jul 3, 2013 at 8:33 PM, Dave Reisner <dreisner at archlinux.org> wrote:
>
> On operating systems we support, the behavior is always such that the
> kernel will do the right thing as far as invalidating the file
> descriptor, regardless of the eventual return value. Therefore,
> potentially looping and calling close multiple times is wrong.
>
> At best, we call close again on an invalid FD and throw a spurious EBADF
> error. At worst, we might close an FD which doesn't belong to us when a
> multi-threaded application opens its own file descriptor between
> iterations of the loop.
>
> Signed-off-by: Dave Reisner <dreisner at archlinux.org>
> ---
> This goes further than the current patch on the ML and removes the CLOSE
> macro
> defined in alpm as well.
>

Looks good to me. It even looks nicer without the macro.


More information about the pacman-dev mailing list