endif
bin_PROGRAMS = mclu
-# Since there are no real C sources (at least, not yet) we have a
-# token C file that is empty, just to keep automake happy. The real
-# sources are *.ml files.
-mclu_SOURCES = empty.c
+mclu_SOURCES = exit.c
+mclu_CPPFLAGS = -I$(OCAMLLIB)
mclu_DEPENDENCIES = $(OBJECTS)
mclu_LINK = \
./link.sh \
/* mclu: Mini Cloud
* Copyright (C) 2014-2015 Red Hat Inc.
+ * Derived from: virt-v2v
+ * Copyright (C) 2009-2015 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-/* intentionally empty */
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <caml/mlvalues.h>
+
+extern int parallel_exit (value rv) __attribute__((noreturn));
+
+int
+parallel_exit (value rv)
+{
+ _exit (Int_val (rv));
+}
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;