[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] do not ignore errors like ENOSPC,EIO when writing to stdout
From: |
Jim Meyering |
Subject: |
[PATCH] do not ignore errors like ENOSPC,EIO when writing to stdout |
Date: |
Sun, 29 Jan 2012 19:22:57 +0100 |
This is incomplete in that I haven't added a test for it
and haven't updated NEWS -- since its effect is limited,
I'm not sure it's worthy of a NEWS entry.
Before:
$ bison --print-datadir > /dev/full
$ bison --print-datadir >&-
$
After:
$ bison --print-datadir > /dev/full
bison: write error: No space left on device
[Exit 1]
$ bison --print-datadir >&-
bison: write error: Bad file descriptor
[Exit 1]
$
>From 581dfdb383842aced19443db6f910fbd02736e23 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 29 Jan 2012 12:50:32 +0100
Subject: [PATCH] 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.
---
bootstrap.conf | 2 +-
lib/.gitignore | 6 ++++++
m4/.gitignore | 3 +++
src/main.c | 3 +++
4 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 599b778..757111c 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 54edced..365b84d 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 c50ed39..901724d 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -166,3 +166,6 @@
/raise.m4
/ssize_t.m4
/strerror_r.m4
+/close-stream.m4
+/closeout.m4
+/fpending.m4
diff --git a/src/main.c b/src/main.c
index e777ca0..3dbac3a 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 ();
--
1.7.9.1.g63eb
- [PATCH] do not ignore errors like ENOSPC,EIO when writing to stdout,
Jim Meyering <=
- Re: [PATCH] do not ignore errors like ENOSPC, EIO when writing to stdout, Akim Demaille, 2012/01/29
- Re: [PATCH] do not ignore errors like ENOSPC, EIO when writing to stdout, Jim Meyering, 2012/01/29
- Re: [PATCH] do not ignore errors like ENOSPC, EIO when writing to stdout, Akim Demaille, 2012/01/30
- Re: [PATCH] do not ignore errors like ENOSPC, EIO when writing to stdout, Jim Meyering, 2012/01/30
- Re: [PATCH] do not ignore errors like ENOSPC, EIO when writing to stdout, Akim Demaille, 2012/01/31
- Re: [PATCH] do not ignore errors like ENOSPC, EIO when writing to stdout, Jim Meyering, 2012/01/31
Re: [PATCH] do not ignore errors like ENOSPC, EIO when writing to stdout, Akim Demaille, 2012/01/31