(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2018 *) (* prerr_endline "internal protocol error"; exit 1 | ReqDie -> prerr_endline "death sentence received"; exit 0 with | e -> prerr_endline ("control channel broken: " ^ Printexc.to_string e); exit 1 in loop () in ignore(Thread.create main ()) let main_channel = ref None let control_channel = ref None let channels = ref None let init_channels () = if !channels <> None then CErrors.anomaly(Pp.str "init_channels called twice."); let () = match !main_channel with | None -> () | Some (Socket(mh,mpr,mpw)) -> channels := Some (open_bin_connection mh mpr mpw); | Some AnonPipe -> let stdin = Unix.in_channel_of_descr (Unix.dup Unix.stdin) in let stdout = Unix.out_channel_of_descr (Unix.dup Unix.stdout) in Unix.dup2 Unix.stderr Unix.stdout; set_binary_mode_in stdin true; set_binary_mode_out stdout true; let stdin = CThread.prepare_in_channel_for_thread_friendly_io stdin in channels := Some (stdin, stdout); in match !control_channel with | None -> () | Some (Socket (ch, cpr, cpw)) -> controller ch cpr cpw | Some AnonPipe -> CErrors.anomaly (Pp.str "control channel cannot be a pipe.") let get_channels () = match !channels with | None -> Printf.eprintf "Fatal error: ideslave communication channels not set.\n"; exit 1 | Some(ic, oc) -> ic, oc let process_id () = Printf.sprintf "%d:%s:%d" (Unix.getpid ()) (if Flags.async_proofs_is_worker () then !Flags.async_proofs_worker_id else "master") (Thread.id (Thread.self ()))