Module Uwt.Process

module Process: sig .. end

Process handles will spawn a new process and allow the user to control it and establish communication channels with it using streams.

type t 
include Uwt.Handle
val to_handle : t -> Uwt.Handle.t
type stdio = 
| Inherit_file of file
| Create_pipe of Uwt.Pipe.t
| Inherit_pipe of Uwt.Pipe.t
| Inherit_stream of Uwt.Stream.t
| Create_pipe_read of Uwt.Pipe.t
| Create_pipe_write of Uwt.Pipe.t
| Create_pipe_duplex of Uwt.Pipe.t (*

Create_pipe_read,Create_pipe_write, etc. determine the direction of flow from the child process' perspective. Previously there was only Create_pipe, which is identic to Create_pipe_read for stdin and Create_pipe_write for stdout and stderr.

This however doesn't allow you the specify a duplex data stream for inter-process communication (and the interface for it is not exposed otherwise for windows). Therefore Create_pipe_duplex, etc. were added later. Create_pipe is now redundant, but left in place in order to not break existing code.

*)
type exit_cb = t -> exit_status:int -> term_signal:int -> unit 
val spawn : ?stdin:stdio ->
?stdout:stdio ->
?stderr:stdio ->
?uid:int ->
?gid:int ->
?verbatim_arguments:bool ->
?detach:bool ->
?hide:bool ->
?env:string list ->
?cwd:string ->
?exit_cb:exit_cb ->
string -> string list -> t uv_result

Initializes the process handle and starts the process.

Possible reasons for failing to spawn would include (but not be limited to) the file to execute not existing, not having permissions to use the setuid or setgid specified, or not having enough memory to allocate for the new process.

The first element of your argument list is supposed to be the path to the program.

verbatim_arguments : default false
detach : default false
hide : default true
val spawn_exn : ?stdin:stdio ->
?stdout:stdio ->
?stderr:stdio ->
?uid:int ->
?gid:int ->
?verbatim_arguments:bool ->
?detach:bool ->
?hide:bool ->
?env:string list ->
?cwd:string ->
?exit_cb:exit_cb -> string -> string list -> t
val disable_stdio_inheritance : unit -> unit

Disables inheritance for file descriptors / handles that this process inherited from its parent. The effect is that child processes spawned by this process don't accidentally inherit these handles.

It is recommended to call this function as early in your program as possible, before the inherited file descriptors can be closed or duplicated.

Note: This function works on a best-effort basis: there is no guarantee that libuv can discover all file descriptors that were inherited. In general it does a better job on Windows than it does on Unix.

val pid : t -> Int_result.int

returns the PID of the spawned process

val pid_exn : t -> int
val process_kill : t -> int -> Int_result.unit

Sends the specified signal to the given process handle. Check the documentation on Uwt.Signal for signal support, specially on Windows.

val process_kill_exn : t -> int -> unit
val kill : pid:int -> signum:int -> Int_result.unit

Sends the specified signal to the given PID. Check the documentation on Uwt.Signal for signal support, specially on Windows.

val kill_exn : pid:int -> signum:int -> unit