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