Re: fd_close() conceals errors

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Mon, 27 Apr 2020 19:45:20 +0000

>I think that depends on the situation. In many cases, you're right,
>there is nothing the program can do about the failure. But in a
>program with user interaction, for example, it may make sense to
>prompt the user to retry or ignore the failure.

  Abort, Ignore, Retry?
  Remember that dreaded message? How many times have you made a choice
that was not "Abort" and actually did something? :P


> It makes sense for
>you to recommend ignoring failures, but I don't see what is gained by
>denying callers the opportunity to decide for themselves.

  Because it's a trap and a footgun all at once, and I don't agree that
there's any sensible decision to make apart from nothing or blowing up
the world. Not for the caller, not for the user - if anything, the
decision should fall back all the way to the admin. And Unix doesn't
have an easy way of doing that - abort() is the closest because it
rings a loud bell.

  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.

--
  Laurent
Received on Mon Apr 27 2020 - 19:45:20 UTC

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