blob: e59a8557ab14545084303ca923b107a975e892dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
(***********************************************************************)
(* *)
(* OCaml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
let print_message delay c =
while true do
print_char c; flush stdout; Thread.delay delay
done
let _ =
Thread.sigmask Unix.SIG_BLOCK [Sys.sigint; Sys.sigterm];
let th1 = Thread.create (print_message 0.6666666666) 'a' in
let th2 = Thread.create (print_message 1.0) 'b' in
let s = Thread.wait_signal [Sys.sigint; Sys.sigterm] in
Printf.printf "Got signal %d, exiting...\n" s
|