guestfish: diagnose stdout write failure
authorJim Meyering <meyering@redhat.com>
Fri, 21 Aug 2009 17:19:39 +0000 (19:19 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 24 Aug 2009 16:15:13 +0000 (18:15 +0200)
Use gnulib's closeout module to ensure any failure to write to
stdout is detected and reported.
* fish/fish.c: Include "closeout.h".
(main): Call atexit (close_stdout);
* bootstrap (modules): Add closeout.

bootstrap
fish/fish.c

index 3fd8811..f5f8aaf 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -50,6 +50,7 @@ gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
 (cd daemon && mkdir -p tests lib && ../$gnulib_tool --update)
 
 modules='
 (cd daemon && mkdir -p tests lib && ../$gnulib_tool --update)
 
 modules='
+closeout
 gitlog-to-changelog
 gnu-make
 gnumakefile
 gitlog-to-changelog
 gnu-make
 gnumakefile
index 156147a..a758810 100644 (file)
@@ -40,6 +40,7 @@
 #include <guestfs.h>
 
 #include "fish.h"
 #include <guestfs.h>
 
 #include "fish.h"
+#include "closeout.h"
 #include "progname.h"
 
 struct mp {
 #include "progname.h"
 
 struct mp {
@@ -140,6 +141,8 @@ main (int argc, char *argv[])
   /* Set global program name that is not polluted with libtool artifacts.  */
   set_program_name (argv[0]);
 
   /* Set global program name that is not polluted with libtool artifacts.  */
   set_program_name (argv[0]);
 
+  atexit (close_stdout);
+
   enum { HELP_OPTION = CHAR_MAX + 1 };
 
   static const char *options = "a:Df:h::im:nrv?Vx";
   enum { HELP_OPTION = CHAR_MAX + 1 };
 
   static const char *options = "a:Df:h::im:nrv?Vx";