[Libguestfs] [PATCH v2 01/23] daemon: Allow parts of the daemon and APIs to be written in OCaml.

Pino Toscano ptoscano at redhat.com
Thu Jul 27 16:17:42 UTC 2017


On Friday, 21 July 2017 22:36:05 CEST Richard W.M. Jones wrote:
> +let commandr ?(flags = []) prog args =
> +  let fold_stdout_on_stderr = List.mem CommandFlagFoldStdoutOnStderr flags in
> +
> +  if verbose () then
> +    eprintf "command: %s %s\n%!"
> +            (if fold_stdout_on_stderr then " fold-stdout-on-stderr" else "")
> +            (stringify_args (prog :: args));
> +
> +  let argv = Array.of_list (prog :: args) in
> +
> +  let stdout_file, stdout_chan = Filename.open_temp_file "cmd" ".out" in
> +  let stderr_file, stderr_chan = Filename.open_temp_file "cmd" ".err" in

These temporary files ought to be removed, otherwise they pile up
within the daemon, and also when the process fails (i.e. when issuing
failwithf).

> +type command_flag =
> +  CommandFlagFoldStdoutOnStderr
> +    (** For broken external commands that send error messages to stdout
> +        (hello, parted) but that don't have any useful stdout information,
> +        use this flag to capture the error messages in the [stderr]
> +        buffer.  Nothing will be captured on stdout if you use this flag. *)

Given command* do not wrap the C functions, what about using labelled
optional arguments instead of the above?

Thanks,
-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20170727/75de5819/attachment.sig>


More information about the Libguestfs mailing list