summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib-unix/common/multicore_fork_domain_alone2.ml
blob: 929ed5ecf7e5b65870fb52e10f2a8f452a3dfa62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(* TEST
include unix
* hasunix
** not-windows
*** bytecode
*** native
*)

(* on Multicore, fork is not allowed is another domain is, and was running. *)
(* this test checks that we can't fork if another domain ran before. *)

let expect_exn ="Unix.fork may not be called while other domains were created"

let () =
  let d = Domain.spawn (fun () -> ()) in
  Domain.join d;
  match Unix.fork () with
  | exception Failure msg ->
     if String.equal msg expect_exn then
       print_endline "OK"
     else
       Printf.printf "failed: expected Failure: %s, got %s\n" expect_exn msg
  | _ -> print_endline "NOK"