5
* remove README-alpha from the distribution.
6
* check automake's support for `help2man'.
7
* check bug-gnu-hello again.
8
* Fix `make check'; cfg. Ulrich's remark at the end of TODO.
9
* submit a new hello.pot.
10
* replace doc/gpl.texi by the one with the recent FSF address.
12
-=-=-=-=-=-=-=-=-=-=-=-=-=- cut here -=-=-=-=-=-=-=-=-=-=-=-=-=-
14
Subject: grep-2.0b: close stdout and make sure it succeeds
15
From: meyering@eng.ascend.com (Jim Meyering)
17
Message-ID: <yzq4t9ucuz5.fsf@boom.eng.ascend.com>
18
Newsgroups: gnu.utils.bug
23
Thanks for taking up the reins!
25
Almost every program that writes a single byte to stdout should
26
do the following just before exiting: close stdout and give a
27
diagnostic if the close fails.
29
Otherwise, write errors can go unreported. You can provoke this
30
by e.g. making grep generate lots of output and redirect that output
31
to a floppy or to any file system that's nearly full.
33
GNU hello should set a good example and do this, too.
35
Here's a patch I've been using for a long time:
37
* src/grep.c: Cause grep to fail if `fclose (stdout)' fails.
39
--- grep.c.orig Wed Jul 16 20:44:20 1997
40
+++ grep.c Wed Jul 16 20:44:30 1997
41
@@ -846,5 +846,8 @@ main(argc, argv)
42
printf(_("(standard input)\n"));
45
+ if (fclose (stdout) == EOF)
46
+ error (_("writing output", errno));
48
exit(errseen ? 2 : status);