diff options
author | Jim Meyering <jim@meyering.net> | 1999-04-04 14:30:30 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-04-04 14:30:30 +0000 |
commit | 42edc330edf5617544515398ebef84916b6f044f (patch) | |
tree | 6c86cf4baa70ea6286649d63ef2da6fe54016764 | |
parent | e0e1dc0bf8e287e08f32d4b6c75060da42d6a67a (diff) | |
download | coreutils-42edc330edf5617544515398ebef84916b6f044f.tar.xz |
fix comments
add FIXME
-rw-r--r-- | lib/closeout.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/closeout.c b/lib/closeout.c index f828d0def..46c9f5750 100644 --- a/lib/closeout.c +++ b/lib/closeout.c @@ -43,14 +43,19 @@ extern int errno; #include "error.h" /* Close standard output, exiting with status STATUS on failure. - If a program writes *anything* to stdout, that program should close - stdout and make sure that the close succeeds. Otherwise, suppose that - you go to the extreme of checking the return status of every function - that does an explicit write to stdout. The last printf can succeed in - writing to the internal stream buffer, and yet the fclose(stdout) could - still fail (due e.g., to a disk full error) when it tries to write - out that buffered data. Thus, you would be left with an incomplete - output file and the offending program would exit successfully. + If a program writes *anything* to stdout, that program should `fflush' + stdout and make sure that it succeeds before exiting. Otherwise, + suppose that you go to the extreme of checking the return status + of every function that does an explicit write to stdout. The last + printf can succeed in writing to the internal stream buffer, and yet + the fclose(stdout) could still fail (due e.g., to a disk full error) + when it tries to write out that buffered data. Thus, you would be + left with an incomplete output file and the offending program would + exit successfully. + + FIXME: note the fflush suggested above is implicit in the fclose + we actually do below. Consider doing only the fflush and/or using + setvbuf to inhibit buffering. Besides, it's wasteful to check the return value from every call that writes to stdout -- just let the internal stream state record |