File: process.mli

package info (click to toggle)
ocaml-obuild 0.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,456 kB
  • sloc: ml: 14,491; sh: 211; ansic: 34; makefile: 11
file content (47 lines) | stat: -rw-r--r-- 1,487 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(** Process execution and management *)

(** Process state *)
type t

(** Process execution result *)
type result =
  | Success of string * string * float  (** stdout, stderr, duration *)
  | Failure of string                   (** stderr *)

(** Delayed process creation *)
type call = unit -> t

val make : string list -> t
(** [make args] creates and starts a new process

    Creates a subprocess with stdout and stderr redirected to pipes.
    The first element of args is the program to execute.

    @param args command line arguments (program + args)
    @return process state *)

val wait : ('a * t) list -> ('a * t) * ('a * t) list
(** [wait processes] waits for one process to finish

    Monitors multiple processes and returns when one completes,
    reading from stdout and stderr until both are closed.

    @param processes list of (task, process) pairs
    @return ((task, finished_process), remaining_processes) *)

val terminate : ('a * t) -> result
(** [terminate (task, process)] cleans up process and returns result

    Waits for process to terminate and collects exit status.

    @param task process pair
    @return Success with outputs and duration, or Failure with stderr *)

val run : string list -> result
(** [run args] executes a single process synchronously

    Convenience function that combines make, wait, and terminate
    for simple single-process execution.

    @param args command line arguments (program + args)
    @return execution result *)