-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathpipe.ml
More file actions
20 lines (17 loc) · 554 Bytes
/
pipe.ml
File metadata and controls
20 lines (17 loc) · 554 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let () =
let pipe = Luv.Pipe.init () |> Result.get_ok in
let redirect = Luv.Process.[
to_parent_pipe ~fd:stdout ~parent_pipe:pipe ()
]
in
ignore (Luv.Process.spawn ~redirect "echo" ["echo"; "Hello,"; "world!"]);
Luv.Stream.read_start pipe begin function
| Error `EOF ->
Luv.Handle.close pipe ignore;
| Error e ->
Printf.eprintf "Read error: %s\n" (Luv.Error.strerror e);
Luv.Handle.close pipe ignore
| Ok buffer ->
print_string (Luv.Buffer.to_string buffer)
end;
ignore (Luv.Loop.run () : bool)