open Printf
open Unix
+(* Call _exit directly, ie. do not run OCaml atexit handlers. *)
+external _exit : int -> 'a = "parallel_exit" "noalloc"
+
let map f xs =
let xs = List.map (
fun x ->
close rfd;
let y = Printexc.catch f x in
(* Write the final value to the pipe. *)
- output_value (out_channel_of_descr wfd) y;
- exit 0
+ let chan = out_channel_of_descr wfd in
+ output_value chan y;
+ flush chan;
+ _exit 0
| pid -> (* parent *)
close wfd;