Up

Module Process

This module is deprecated; please use Async.Std.Process.

Signature

module Output : sig .. end
val create : ?kill:unit Async.Std.Deferred.t -> ?kill_how:[
| `by_pid
| `by_group
] -> prog:string -> args:string list -> ?env:Async.Std.Process.env -> ?working_dir:string -> ?stdin:string -> f:(Core.Std.Pid.t -> stdin:Async.Std.Writer.t -> stdout:Async.Std.Reader.t -> stderr:Async.Std.Reader.t -> 'a Async.Std.Deferred.t) -> unit -> ('a * Core.Std.Unix.Exit_or_signal.t) Async.Std.Deferred.t

create_process cmd f runs cmd and hands details of the process to f. When f is determined, or when f throws an exception, the background process is killed gracefully (TERM, wait, then KILL), all file descriptors are closed, and the process is reaped

type file_descr = Core.Std.Unix.File_descr.t
val create_fds : kill:unit Async.Std.Deferred.t -> ?kill_how:[
| `by_pid
| `by_group
] -> prog:string -> args:string list -> ?env:[
| `Replace_raw of string list
] -> stdin:file_descr -> stdout:file_descr -> stderr:file_descr -> f:(Core.Std.Pid.t -> unit) -> unit -> Async.Std.Unix.Exit_or_signal.t Async.Std.Deferred.t

create_fds... like create, except that the three file_descrs to be used for the stdin/stdout/stderr of the forked process are passed in. The passed-in file_descrs might for example have been obtained by a called to Unix.pipe().

val create_fds' : kill:unit Async.Std.Deferred.t -> ?kill_how:[
| `by_pid
| `by_group
] -> prog:string -> args:string list -> ?env:[
| `Replace_raw of string list
] -> stdin:file_descr -> stdout:file_descr -> stderr:file_descr -> f:(Core.Std.Pid.t -> 'a Async.Std.Deferred.t) -> unit -> ('a * Async.Std.Unix.Exit_or_signal.t) Async.Std.Deferred.t

create_fds'... like create_fds except that we wait for caller's f to become determined before calling Unix.waitpid. Also, result of caller's f is return with Exit_or_signal.t

val open_in : ?is_ok:(Core.Std.Unix.Exit_or_signal.t -> bool) -> ?kill:unit Async.Std.Deferred.t -> prog:string -> args:string list -> unit -> Async.Std.Reader.t Output.t Async.Std.Deferred.t

open_in ~prog ~args runs prog with args and returns a readers connected to stdout and stderr. When both of those readers are closed then the process is reaped (and killed if necessary). is_ok defaults to Core.Std.Unix.Exit_or_signal.ok.

type 'a backtick = ?kill:unit Async.Std.Deferred.t -> ?env:Async.Std.Process.env -> prog:string -> args:string list -> ?working_dir:string -> ?stdin:string -> unit -> 'a

backtick_status ~prog ~args runs prog with args and returns the full stdout and stderr as strings, together with the process status. If stdin is provided, it will be written to the stdin of the program, but no guarantees are made as to whether the program actually reads this data. In particular, the program may close stdin, or exit before the data has been read; no error is raised in these circumstances. This behaviour is akin to: echo stdin | ... at the shell prompt.

val backtick : string Output.t Async.Std.Deferred.t backtick

backtick ~prog ~args runs prog with args and returns the full stdout and stderr as strings (ignoring the process status)

val backtick_new : (string, exn) Core.Std.Result.t Async.Std.Deferred.t backtick
val backtick_new_exn : string Async.Std.Deferred.t backtick