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

Pino Toscano ptoscano at redhat.com
Wed Sep 17 11:47:02 UTC 2014


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




More information about the Libguestfs mailing list