541 |
let oc = open_out "mlnet.pid" in |
let oc = open_out "mlnet.pid" in |
542 |
output_string oc ( Printf.sprintf "%s\n" ( string_of_int ( Unix.getpid () ) ) ); |
output_string oc ( Printf.sprintf "%s\n" ( string_of_int ( Unix.getpid () ) ) ); |
543 |
close_out oc; |
close_out oc; |
544 |
CommonGlobals.do_at_exit (fun _ -> Sys.remove "mlnet.pid" ); |
CommonGlobals.do_at_exit (fun _ -> try Sys.remove "mlnet.pid" with _ -> ()); |
545 |
if !verbose then lprintf_nl (_b "Starting with pid %s") (string_of_int(Unix.getpid ())) |
if !verbose then lprintf_nl (_b "Starting with pid %s") (string_of_int(Unix.getpid ())) |
546 |
); |
); |
547 |
|
|
589 |
|
|
590 |
if Autoconf.system <> "windows" then |
if Autoconf.system <> "windows" then |
591 |
MlUnix.set_signal Sys.sigchld |
MlUnix.set_signal Sys.sigchld |
592 |
(Sys.Signal_handle (fun _ -> lprintf_nl "SIGCHLD")); |
(Sys.Signal_handle (fun _ -> lprintf_nl "Received SIGCHLD, doing nothing")); |
593 |
|
|
594 |
if Autoconf.system <> "windows" then |
if Autoconf.system <> "windows" then |
595 |
MlUnix.set_signal Sys.sighup |
MlUnix.set_signal Sys.sighup |
596 |
(Sys.Signal_handle (fun _ -> |
(Sys.Signal_handle (fun _ -> |
597 |
lprintf_nl "SIGHUP"; |
lprintf_nl "Received SIGHUP, closing all files/sockets"; |
598 |
BasicSocket.close_all (); |
BasicSocket.close_all (); |
599 |
Unix32.close_all () |
Unix32.close_all () |
600 |
)); |
)); |
601 |
|
|
602 |
if Autoconf.system <> "windows" then |
if Autoconf.system <> "windows" then |
603 |
MlUnix.set_signal Sys.sigpipe |
MlUnix.set_signal Sys.sigpipe |
604 |
(Sys.Signal_handle (fun _ -> lprintf_nl "SIGPIPE")); |
(Sys.Signal_handle (fun _ -> if !verbose then lprintf_nl "Received SIGPIPE, doing nothing")); |
605 |
|
|
606 |
MlUnix.set_signal Sys.sigint |
MlUnix.set_signal Sys.sigint |
607 |
(Sys.Signal_handle (fun _ -> lprintf_nl "SIGINT"; |
(Sys.Signal_handle (fun _ -> lprintf_nl "Received SIGINT, stopping MLDonkey..."; |
608 |
CommonGlobals.exit_properly 0)); |
CommonGlobals.exit_properly 0)); |
609 |
|
|
610 |
MlUnix.set_signal Sys.sigterm |
MlUnix.set_signal Sys.sigterm |
611 |
(Sys.Signal_handle (fun _ -> lprintf_nl "SIGTERM"; |
(Sys.Signal_handle (fun _ -> lprintf_nl "Received SIGTERM, stopping MLDonkey..."; |
612 |
CommonGlobals.exit_properly 0)); |
CommonGlobals.exit_properly 0)); |
613 |
|
|
614 |
if !verbose then lprintf_nl (_b "Activated system signal handling"); |
if !verbose then lprintf_nl (_b "Activated system signal handling"); |