From: David Scott Date: Mon, 21 Dec 2009 21:34:31 +0000 (+0000) Subject: CA-36084: pass an optional environment to Forkhelpers.execute_command_get_output X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a3864833e63f9108a855e8c2edecc3772ebd1fa4;p=xcp%2Fxen-api-libs.git CA-36084: pass an optional environment to Forkhelpers.execute_command_get_output Signed-off-by: David Scott --- diff --git a/stdext/forkhelpers.ml b/stdext/forkhelpers.ml index 5b259c2..952e5f4 100644 --- a/stdext/forkhelpers.ml +++ b/stdext/forkhelpers.ml @@ -152,10 +152,10 @@ let safe_close_and_exec ?env stdin stdout stderr (fds: (string * Unix.file_descr close_fds -let execute_command_get_output cmd args = +let execute_command_get_output ?env cmd args = match with_logfile_fd "execute_command_get_out" (fun out_fd -> with_logfile_fd "execute_command_get_err" (fun err_fd -> - let (sock,pid) = safe_close_and_exec None (Some out_fd) (Some err_fd) [] cmd args in + let (sock,pid) = safe_close_and_exec ?env None (Some out_fd) (Some err_fd) [] cmd args in match Fecomms.read_raw_rpc sock with | Fe.Finished x -> Unix.close sock; x | _ -> Unix.close sock; failwith "Communications error" diff --git a/stdext/forkhelpers.mli b/stdext/forkhelpers.mli index 590db8c..bedb87e 100644 --- a/stdext/forkhelpers.mli +++ b/stdext/forkhelpers.mli @@ -17,7 +17,7 @@ (** [execute_command_get_output cmd args] runs [cmd args] and returns (stdout, stderr) on success (exit 0). On failure this raises [Spawn_internal_error(stderr, stdout, Unix.process_status)] *) -val execute_command_get_output : string -> string list -> string * string +val execute_command_get_output : ?env:string array -> string -> string list -> string * string (** Thrown by [execute_command_get_output] if the subprocess exits with a non-zero exit code *) exception Spawn_internal_error of string * string * Unix.process_status