forked from facebook/pyre-check
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlwtSubprocess.ml
More file actions
25 lines (22 loc) · 757 Bytes
/
lwtSubprocess.ml
File metadata and controls
25 lines (22 loc) · 757 Bytes
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
(* Copyright (c) 2016-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. *)
module Completed = struct
type t = {
stdout: string;
stderr: string;
status: Unix.process_status;
}
let create_from_process process =
let open Lwt.Infix in
(* Wait for it to finish *)
process#status
>>= fun status ->
Lwt_io.read process#stdout
>>= fun stdout ->
Lwt_io.read process#stderr >>= fun stderr -> Lwt.return { stdout; stderr; status }
end
let run ~arguments executable =
let lwt_command = executable, Array.of_list (executable :: arguments) in
Lwt_process.with_process_full lwt_command Completed.create_from_process