Jim Meyering <jim <at> meyering.net> writes:
> - if (!dry_run && close_stream (stdout))
> + if (!dry_run && (ferror (stdout) || fflush (stdout) != 0))
That means #include "close-stream.h" is no longer required. Also, should we
try the fflush before ferror?
On the other hand, aren't there situations with NFS where fflush() will succeed
at getting the data into a kernel buffer, but fclose() then fails because the
kernel was unable to flush its buffers over the network? Maybe we have to do
something like dd, where we keep this location calling close_stream after all,
then use a custom atexit() hook that decides whether to call close_stdout() or
just manually handle only stderr?
--
Eric Blake