summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-01-29 12:50:32 +0100
committerAkim Demaille <demaille@gostai.com>2012-01-31 09:26:08 +0100
commite187b40d317f2bcff21779a774a767f51c0fe276 (patch)
tree4f3d26ef92dce23c075788ad1e1daa39a4dc15b0
parentec94982becc67543aa05f67ea861f689f1e4ddd0 (diff)
downloadbison-e187b40d317f2bcff21779a774a767f51c0fe276.tar.gz
do not ignore errors like ENOSPC,EIO when writing to stdout
Standard output was never explicitly closed, so we could not detect failure. Thus, bison would ignore the errors of writing to a full file system and getting an I/O error on write, but only for standard output, e.g., for --print-localedir, --print-datadir, --help and some verbose output. Now, "bison --print-datadir > /dev/full" reports the write failure: bison: write error: No space left on device Before, it would exit 0 with no diagnostic, implying success. This is not an issue for "--output=-" or the other FILE-accepting command-line options, because unlike most other GNU programs, an output file argument of "-" is treated as the literal "./-", rather than standard output. * bootstrap.conf (gnulib_modules): Add closeout. * src/main.c: Include "closeout.h". Use atexit to ensure we close stdout. * .gitignore: Ignore new files pulled in via gnulib-tool. (cherry picked from commit acb5895680611f8beb497b41694d9686f2932c50) Conflicts: m4/.gitignore
-rw-r--r--bootstrap.conf2
-rw-r--r--lib/.gitignore6
-rw-r--r--m4/.gitignore24
-rw-r--r--src/main.c3
4 files changed, 22 insertions, 13 deletions
diff --git a/bootstrap.conf b/bootstrap.conf
index 90ba6e56..7d6f3fbd 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -17,7 +17,7 @@
# gnulib modules used by this package.
gnulib_modules='
- announce-gen argmatch assert calloc-posix close config-h c-strcase
+ announce-gen argmatch assert calloc-posix close closeout config-h c-strcase
configmake dirname error extensions fdl fopen-safer gendocs getopt-gnu
gettext git-version-gen gitlog-to-changelog
gpl-3.0 hash inttypes isnan javacomp-script
diff --git a/lib/.gitignore b/lib/.gitignore
index 54edced3..365b84d0 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -259,3 +259,9 @@
/strerror-override.h
/strerror_r.c
/xalloc-oversized.h
+/close-stream.c
+/close-stream.h
+/closeout.c
+/closeout.h
+/fpending.c
+/fpending.h
diff --git a/m4/.gitignore b/m4/.gitignore
index f46e1646..01e5f645 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -1,4 +1,3 @@
-
/00gnulib.m4
/alloca.m4
/argmatch.m4
@@ -6,7 +5,9 @@
/assert.m4
/calloc.m4
/cloexec.m4
+/close-stream.m4
/close.m4
+/closeout.m4
/codeset.m4
/config-h.m4
/configmake.m4
@@ -28,10 +29,12 @@
/fcntl_h.m4
/float_h.m4
/fopen.m4
+/fpending.m4
/fpieee.m4
/fprintf-posix.m4
/frexp.m4
/frexpl.m4
+/fstat.m4
/getdtablesize.m4
/getopt.m4
/gettext.m4
@@ -57,6 +60,8 @@
/iswblank.m4
/javacomp.m4
/javaexec.m4
+/largefile.m4
+/ldexp.m4
/ldexpl.m4
/lib-ld.m4
/lib-link.m4
@@ -78,10 +83,13 @@
/memchr.m4
/mmap-anon.m4
/mode_t.m4
+/msvc-inval.m4
+/msvc-nothrow.m4
/multiarch.m4
/nls.m4
/nocrash.m4
/open.m4
+/pathmax.m4
/perror.m4
/pipe.m4
/pipe2.m4
@@ -95,6 +103,7 @@
/progtest.m4
/quote.m4
/quotearg.m4
+/raise.m4
/rawmemchr.m4
/realloc.m4
/sched_h.m4
@@ -112,6 +121,7 @@
/spawn-pipe.m4
/spawn_h.m4
/sprintf-posix.m4
+/ssize_t.m4
/stat.m4
/stdbool.m4
/stddef_h.m4
@@ -124,6 +134,7 @@
/strchrnul.m4
/strdup.m4
/strerror.m4
+/strerror_r.m4
/string_h.m4
/strndup.m4
/strnlen.m4
@@ -156,14 +167,3 @@
/xalloc.m4
/xsize.m4
/xstrndup.m4
-
-/fstat.m4
-/largefile.m4
-/ldexp.m4
-/msvc-inval.m4
-/msvc-nothrow.m4
-/pathmax.m4
-/raise.m4
-/ssize_t.m4
-/strerror_r.m4
-/gnulib-comp.m4
diff --git a/src/main.c b/src/main.c
index e777ca04..3dbac3a9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,6 +28,7 @@
#include <timevar.h>
#include "LR0.h"
+#include "closeout.h"
#include "complain.h"
#include "conflicts.h"
#include "derives.h"
@@ -62,6 +63,8 @@ main (int argc, char *argv[])
(void) bindtextdomain ("bison-runtime", LOCALEDIR);
(void) textdomain (PACKAGE);
+ atexit (close_stdout);
+
uniqstrs_new ();
muscle_init ();