Re: fd_close() conceals errors

From: Paul Jarc <>
Date: Wed, 06 May 2020 02:48:17 -0400

"Laurent Bercot" <> wrote:
> If you are in the rare case where you need to check the return code from
> close(), then you should probably use close() directly, not a wrapper
> around it.

I wouldn't go quite that far--I'd say a wrapper to handle EINTR is
useful in either case--but I agree that it's worth thinking carefully
about which errors, if any, are worth failing for in any given case,
rather than failing for everything. Mainly I'd fail for EIO on
close(), just as on write(). But in some cases, we can know that EIO
is impossible, or can be caught later. Say, if we never did any
writing, or if we're closing a dup'ed descriptor for a file that's
still open. After checking over my own code, I've found several cases
like that. I've got my own wrapper now for the cases where I want to
detect EIO.
Received on Wed May 06 2020 - 06:48:17 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC