summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib-unix/common/fork_cleanup_systhreads.ml
blob: a25f217b97a6142408f36e90b009aa4d92125048 (plain)
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
(* TEST
 include systhreads;
 hassysthreads;
 not-windows;
 {
   bytecode;
 }{
   native;
 }
*)

(* this test checks that the domain lock is properly reinitialized
   in the child process after fork.
   See: https://github.com/ocaml-multicore/ocaml-multicore/issues/471 *)

let () =
  let th = Thread.create (fun () -> Thread.delay 0.5) () in
  let fd = Unix.dup Unix.stdout in
  match Unix.fork () with
  | 0 ->
     Unix.close fd;
     print_endline "OK"
  | _ ->
     Unix.close fd;
     Thread.join th