detecting write failure [Re: [Libguestfs] [PATCH] virt-cat: Remove some unused Perl module includes.

Jim Meyering jim at meyering.net
Wed Sep 23 11:18:06 UTC 2009


Richard W.M. Jones wrote:
> Subject: [PATCH 3/4] virt-cat: Remove some unused Perl module includes.
>
> ---
>  cat/virt-cat.pl |    3 ---
>  1 files changed, 0 insertions(+), 3 deletions(-)
>
> diff --git a/cat/virt-cat.pl b/cat/virt-cat.pl
> index 8db5348..748dbb8 100755
> --- a/cat/virt-cat.pl
> +++ b/cat/virt-cat.pl
> @@ -25,9 +25,6 @@ use Sys::Guestfs::Lib qw(open_guest get_partitions resolve_windows_path
>    inspect_operating_systems mount_operating_system);
>  use Pod::Usage;
>  use Getopt::Long;
> -use Data::Dumper;
> -use File::Temp qw/tempdir/;
> -use XML::Writer;
>  use Locale::TextDomain 'libguestfs';

These look fine.

Unrelated to this particular change, you may want to
add these lines to virt-cat:

  END { # use File::Coda; # http://meyering.net/code/Coda/
    defined fileno STDOUT or return;
    close STDOUT and return;
    warn "$ME: failed to close standard output: $!\n";
    $? ||= 1;
  }

Otherwise, virt-cat could fail to detect/report write errors.

Try this:

    virt-cat /some/file > /dev/full

It should fail.

This is a general problem in nearly every perl script
that writes to stdout.




More information about the Libguestfs mailing list