[Libguestfs] [PATCH] Use open_process_full in compressed file reading

Richard W.M. Jones rjones at redhat.com
Wed Sep 17 12:17:58 UTC 2014


On Wed, Sep 17, 2014 at 01:47:02PM +0200, Pino Toscano wrote:
> Since only few bytes of the compressed file are read, closing the stdout
> of the process will cause it to complain about that.
> Switch to open_process_full instead of open_process_in, so we can close
> also stderr and avoid that harmless error message.
> ---
>  src/build.ml | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/build.ml b/src/build.ml
> index 7011731..500ce33 100644
> --- a/src/build.ml
> +++ b/src/build.ml
> @@ -322,13 +322,13 @@ and get_file_content file buf len =
>  
>  and get_compressed_file_content zcat file =
>    let cmd = sprintf "%s %s" zcat (quote file) in
> -  let chan = open_process_in cmd in
> +  let chan_out, chan_in, chan_err = open_process_full cmd [||] in
>    let buf = String.create 512 in
> -  let len = input chan buf 0 (String.length buf) in
> +  let len = input chan_out buf 0 (String.length buf) in
>    (* We're expecting the subprocess to fail because we close the pipe
>     * early, so:
>     *)
> -  ignore (close_process_in chan);
> +  ignore (Unix.close_process_full (chan_out, chan_in, chan_err));
>  
>    get_file_content file buf len
>  
> -- 
> 1.9.3

I've not seen the error message, but ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list