module Proc:An Ocaml abstraction for UNIX processes. Thesig..end
Proc module takes responsiblity for reaping
children and provides access to exit codes through abstract
Proc.t objects. (If you need to reap yourself,
Proc.don't_autoreap will turn off the Sys.sigchld handler, and
Proc.autoreap will turn it back on.)
Because the Proc module is responsible for reaping, it makes
exit status available as many times as necessary, though
Proc.wait and Proc.status_of_proc.
It's also possible to construct a Proc.t object from a pid
(int) even if the process wasn't created using this library. In
this case, the library detects whether the process is a child or
not. We don't allow waiting
on or getting the status of non-child processes, because UNIX
doesn't.
Much of this design is due to Cash/Scsh.
exception Not_child
type t
typestatus =Unix.process_status=
| |
WEXITED of |
(* | The process terminated normally by exit; the argument is the return code. | *) |
| |
WSIGNALED of |
(* | The process was killed by a signal; the argument is the signal number. | *) |
| |
WSTOPPED of |
(* | The process was stopped by a signal; the argument is the signal number. | *) |
val fork : unit -> t optionSome t in the parent and None in the childval spawn : ?quiet:bool -> (unit -> unit) -> tval kill : ?raise:bool -> int -> t -> unitval wait : t -> statusval wait_any : t list -> tval status_of_proc : t -> status optionval is_child : t -> boolval pid_of_proc : t -> intval proc_of_pid : int -> tval procs_of_pid : int -> t listval exit_with_status : status -> 'aval autoreap : unit -> unitval don't_autoreap : unit -> unitval system : string -> statusval system_program : ?path:bool -> string -> ?argv0:string -> string list -> statusval vfork : string -> tval vfork_program : ?path:bool -> string -> ?argv0:string -> string list -> tval exec : string -> 'aval exec_program : ?path:bool -> string -> ?argv0:string -> string list -> 'atype execspec = {
|
path : |
(* | Search the path (default true) | *) |
|
program : |
(* | Executable to run | *) |
|
argv0 : |
(* | Zeroth argument (default program) | *) |
|
args : |
(* | Additional arguments | *) |
val execspec : ?path:bool -> string -> ?argv0:string -> string list -> execspec
val with_execspec : execspec ->
(?path:bool -> string -> ?argv0:string -> string list -> 'a) -> 'a