summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib-unix/common/fork_cleanup_systhreads.ml
blob: db0ebf4f6d92931c171a8f734d246bd770444510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(* TEST
* hassysthreads
include systhreads
** 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