Skip to content

Instantly share code, notes, and snippets.

@yoshihiro503
Last active December 14, 2015 02:19
Show Gist options
  • Save yoshihiro503/5012456 to your computer and use it in GitHub Desktop.
Save yoshihiro503/5012456 to your computer and use it in GitHub Desktop.
ocaml-4.00.1 および ocaml-3.12.1で確認。バイトコードでもネイティブでも起きる。 -vmthreadだと起きない $ ocamlc -thread unix.cma threads.cma mumumus.ml
(*
(*なぜかこの関数定義があると下記でSIGALRMが呼ばれなくなる *)
let hogehoge f x = Thread.create f x
*)
let wait () =
let m = Mutex.create () in
Mutex.lock m;
let c = Condition.create () in
Condition.wait c m
let _ =
Sys.set_signal Sys.sigalrm (Sys.Signal_handle
(fun n -> print_endline "HOGE"));
ignore (Unix.alarm 1);
wait ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment