Improve error message on misplaced async modifiers
[hiphop-php.git] / hphp / hack / src / utils / lwt_utils.mli
blob3b4114946950abb25b9d9a6b805ffeeaae3745f4
1 val select:
2 Unix.file_descr list ->
3 Unix.file_descr list ->
4 Unix.file_descr list ->
5 float ->
6 (Unix.file_descr list * Unix.file_descr list * Unix.file_descr list) Lwt.t
7 (** Drop-in replacement for [Unix.select] that works even when the Lwt main loop
8 is running (i.e. your function has [Lwt_main.run] somewhere higher up in the
9 call stack).
11 The Lwt main loop is an event loop pumped by [Unix.select], and so regular
12 [Unix.select] calls are prone to raising `EINTR`. The implementation of this
13 function does not use [Unix.select] at all, but Lwt primitives that accomplish
14 the same thing.
17 module Process_success: sig
18 type t = {
19 command_line: string;
20 stdout: string;
21 stderr: string;
23 end
25 module Process_failure: sig
26 type t = {
27 command_line: string;
28 process_status: Unix.process_status;
29 stdout: string;
30 stderr: string;
31 exn: exn option;
34 val to_string: t -> string
35 end
37 val exec_checked:
38 ?input:string ->
39 ?env:string array ->
40 string ->
41 string array ->
42 (Process_success.t, Process_failure.t) Lwt_result.t
43 (** Run a command with a given input and return the output. If the command exits
44 with an exit status other than zero, raises [Process_failure] instead.
46 NOTE: on cancellation, this function will not kill the underlying process. (I
47 tried to implement it, but after killing the process, both [Lwt_io.close] and
48 [Lwt_io.abort] would hang when trying to close the process's
49 stdin/stdout/stderr.)
52 val try_finally:
53 f:(unit -> 'a Lwt.t) ->
54 finally:(unit -> unit Lwt.t) ->
55 'a Lwt.t
56 (** Asynchronous version of [Utils.try_finally]. Run and wait for [f] to
57 complete, and be sure to invoke [finally] asynchronously afterward, even if [f]
58 raises an exception. *)
60 val read_all: string -> (string, string) Lwt_result.t
61 (** Reads all the contents from the given file on disk, or returns an error
62 message if unable to do so. *)