1
(* A toploop that is running in a worker process. You also need to
2
link with toplevellib.cma (see Makefile).
4
There is a new directive #spawn which may be used to create new
5
workers. Just quit them with #quit.
7
Bad interaction with ledit: SIGINT from ledit is only sent to the
8
master process but not to the whole process group.
10
FIXME: SIGINT does not work properly
13
module Unit_encap = Netplex_encap.Make_encap(struct type t = unit end)
17
Netmcore.Debug.enable := true
25
(* just reference this module, so the directives get initialized *)
28
Unix.openfile "." [Unix.O_RDONLY] 0
31
Netsys_signal.keep_away_from Sys.sigint;
32
Sys.set_signal Sys.sigint Sys.Signal_ignore
36
("Netmcore: Starting toploop in worker child [PID=" ^
37
string_of_int (Unix.getpid()) ^ "]");
38
Netsys_posix.fchdir wd_fd;
40
Toploop.loop Format.std_formatter;
41
(* We never get here! *)
44
let toploop_fork, toploop_join =
51
let spawn_toploop () =
53
Netmcore.start ~inherit_resources:`All toploop_fork (Unit_encap.wrap()) in
54
Sys.catch_break false;
55
ignore(Netmcore.join toploop_join pid);
58
("Netmcore: Returning to toploop in worker child [PID=" ^
59
string_of_int (Unix.getpid()) ^ "]")
62
Hashtbl.add Toploop.directive_table
64
(Toploop.Directive_none spawn_toploop)
68
~socket_directory:"/tmp/t_toploop"
69
~first_process:(fun() -> Netmcore.start toploop_fork (Unit_encap.wrap()))