[Libguestfs] [PATCH libguestfs 4/5] guestfish: diagnose stdout write failure
Richard W.M. Jones
rjones at redhat.com
Mon Aug 24 10:54:26 UTC 2009
On Mon, Aug 24, 2009 at 12:21:56PM +0200, Jim Meyering wrote:
> From: Jim Meyering <meyering at redhat.com>
>
> 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.
>
> (emit print_*_indent): Likewise, s/int/unsigned int/
> ---
> bootstrap | 1 +
> fish/fish.c | 3 +++
> 2 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/bootstrap b/bootstrap
> index 3fd8811..f5f8aaf 100755
> --- a/bootstrap
> +++ b/bootstrap
> @@ -50,6 +50,7 @@ gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
> (cd daemon && mkdir -p tests lib && ../$gnulib_tool --update)
>
> modules='
> +closeout
> gitlog-to-changelog
> gnu-make
> gnumakefile
> diff --git a/fish/fish.c b/fish/fish.c
> index 964c906..1790c1a 100644
> --- a/fish/fish.c
> +++ b/fish/fish.c
> @@ -40,6 +40,7 @@
> #include <guestfs.h>
>
> #include "fish.h"
> +#include "closeout.h"
> #include "progname.h"
>
> struct mp {
> @@ -143,6 +144,8 @@ main (int argc, char *argv[])
> /* getopt_long uses argv[0], so give it the sanitized name, too. */
> argv[0] = bad_cast (program_name);
>
> + atexit (close_stdout);
> +
> enum { HELP_OPTION = CHAR_MAX + 1 };
>
> static const char *options = "a:Df:h::im:nrv?Vx";
> --
> 1.6.4.378.g88f2f
ACK.
Rich.
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 75 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
More information about the Libguestfs
mailing list