summaryrefslogtreecommitdiff
path: root/otherlibs/unix/unixLabels.mli
diff options
context:
space:
mode:
authorNicolás Ojeda Bär <n.oje.bar@gmail.com>2018-05-24 11:10:36 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-05-24 11:10:36 +0200
commit76f30d00f38589ccafd0bc06116a54526dfe3cef (patch)
treec7979191ca6b85d67950d2e04dbd05fcfbf71b69 /otherlibs/unix/unixLabels.mli
parente3f792a14b7349daee53d0ee8813f9f60e779624 (diff)
downloadocaml-76f30d00f38589ccafd0bc06116a54526dfe3cef.tar.gz
Unix: add open_process_args{,_in,_out,_full} (#1792)
The idea is to add a variant of the Unix.open_process{,_in,_out,_full} functions that work with a pair (program, args) directly, without going through the system shell, which introduces extra complexity (in particular, with respect to quoting). I used the name Unix.open_process_args which is the one suggested in ocaml-batteries-team/batteries-included#858, but I am not completely sold on it. One uses the usual "close" functions Unix.close_process{,_in,_out,_full} with the new functions as well. The "old" functions Unix.open_process{,_in,_out,_full} are re-implemented in terms of the "new" functions, so I did not feel pressed to add new tests. Addresses: MPR#7794.
Diffstat (limited to 'otherlibs/unix/unixLabels.mli')
-rw-r--r--otherlibs/unix/unixLabels.mli35
1 files changed, 35 insertions, 0 deletions
diff --git a/otherlibs/unix/unixLabels.mli b/otherlibs/unix/unixLabels.mli
index a78738bbb6..cdfecc8962 100644
--- a/otherlibs/unix/unixLabels.mli
+++ b/otherlibs/unix/unixLabels.mli
@@ -666,6 +666,41 @@ val open_process_full :
of channels connected respectively to the standard output, standard input,
and standard error of the command. *)
+val open_process_args_in : string -> string array -> in_channel
+(** High-level pipe and process management. The first argument specifies the
+ command to run, and the second argument specifies the argument array passed
+ to the command. This function runs the command in parallel with the program.
+ The standard output of the command is redirected to a pipe, which can be read
+ via the returned input channel.
+
+ @since 4.08.0 *)
+
+val open_process_args_out : string -> string array -> out_channel
+(** Same as {!Unix.open_process_args_in}, but redirect the standard input of the
+ command to a pipe. Data written to the returned output channel is sent to
+ the standard input of the command. Warning: writes on output channels are
+ buffered, hence be careful to call {!Pervasives.flush} at the right times to
+ ensure correct synchronization.
+
+ @since 4.08.0 *)
+
+val open_process_args : string -> string array -> in_channel * out_channel
+(** Same as {!Unix.open_process_args_out}, but redirects both the standard input
+ and standard output of the command to pipes connected to the two returned
+ channels. The input channel is connected to the output of the command, and
+ the output channel to the input of the command.
+
+ @since 4.08.0 *)
+
+val open_process_args_full :
+ string -> string array -> string array -> in_channel * out_channel * in_channel
+(** Similar to {!Unix.open_process_args}, but the third argument specifies the
+ environment passed to the command. The result is a triple of channels
+ connected respectively to the standard output, standard input, and standard
+ error of the command.
+
+ @since 4.08.0 *)
+
val close_process_in : in_channel -> process_status
(** Close channels opened by {!UnixLabels.open_process_in},
wait for the associated command to terminate,