On Wed, Sep 23, 2009 at 01:18:06PM +0200, Jim Meyering wrote:
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.
It turns out that virt-cat does catch this error already, or more
precisely guestfs_download catches the error in the write to
/dev/stdout and does the right thing:
$ sudo ./cat/run-cat-locally /dev/vg_trick/F11x64 /boot/grub/grub.conf > /dev/full
download: /dev/stdout: write: No space left on device at
/home/rjones/d/libguestfs/cat/virt-cat.pl line 162.
$ echo $?
28
I'm not entirely sure where code 28 comes from.
However, this is a good suggestion in the general case and I'll have
to remember it for other perl scripts.
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