[musl] Re: Tweaking the program name for <err.h> functions

Florian Weimer fweimer at redhat.com
Tue Mar 12 13:54:09 UTC 2024


* Gabriel Ravier:

> Doing this would break many programs, such as:
> - most of coreutils, e.g. programs like ls, cat or head, since they
>   always `close` their input and output descriptors (when they've
>   written or read something) to make sure to diagnose all errors

A slightly better way to do this is to do fflush (stdout) followed by
error checking on close (dup (fileno (stdout))).  We can't do this
implicitly as part of fflush because it potentially breaks legacy
(non-OFD) POSIX file locking, at least not without parsing /proc and
whatnot.  The close system call is how the Linux NFS client reports
ENOSPC errors without performing a costly fsync on the server.  We don't
have a better interface for this.

Thanks,
Florian



More information about the libbsd mailing list