-
Notifications
You must be signed in to change notification settings - Fork 2
/
run-pipe.ml
33 lines (31 loc) · 1.46 KB
/
run-pipe.ml
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
(***********************************************************************)
(* Cash *)
(* *)
(* Bruno Verlyck, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 2002 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the GNU Lesser General Public License. *)
(* *)
(* Cash is based on Scsh, by Olin Shivers. *)
(***********************************************************************)
open Cash;
(* Ou mettre Early. *)
value test_run_with_port_plus_proc () =
do {
ignore (autoreap_policy ~policy:No_autoreaping ());
let (chan, child_proc) =
run_with_inchan_plus_proc
(fun () -> do { print_string "turlututu chapeau pointu\n"; exit 1 })
;
Unix.sleep 2;
with_stdin chan (char_filter Char.uppercase);
print_endline
(match wait child_proc with
[ WEXITED exit_val -> "Exit: " ^ string_of_int exit_val
| WSIGNALED signum -> "Signal: " ^ string_of_int signum
| WSTOPPED _ -> "Oh, my subprocess is stopped?" ])
}
;
if Sys.interactive.val then ()
else Unix.handle_unix_error test_run_with_port_plus_proc ();