POSIX requires us to print an error message and exit non-zero if
writing to stdout fails. This can only happen if sflag is unset.
MFC after: 3 days
Sponsored by: Klara, Inc.
Differential D47020
cmp: Check the status of stdout. des on Oct 8 2024, 10:02 PM. Authored by Tags None Referenced Files
Details
POSIX requires us to print an error message and exit non-zero if MFC after: 3 days
Diff Detail
Event TimelineComment Actions
But almost all of them are exiting with a non-zero status. Don't you just need to handle those that exit with status 0? Comment Actions Strictly speaking, yes- other errors should take precedence over a flush error, even if we could have encountered the flush error first but didn't bother error checking all of the writes to stdout. Comment Actions DIFF_EXIT is non-zero but not an error. Unless -s was specified, it is preceded by a message to stdout, and POSIX requires us to not only exit non-zero but also print an error message to stderr if writing to stdout fails. I suppose this would be clearer if I rewrote cmp to return non-error results back to main so there was only a single non-error exit point, and then try to fflush(stdout) iff !sflag, rather than use atexit().
|