10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-10-04 23:35:58 +02:00

Cleaning after Ctrl-C

This commit is contained in:
Anthony Scemama 2016-03-03 13:57:33 +01:00
parent 453a29d607
commit b66cddbe4d
4 changed files with 10 additions and 9 deletions

View File

@ -833,12 +833,13 @@ let run ?(daemon=true) ezfio_filename =
(* Handle signals *) (* Handle signals *)
let handler s = let handler s =
Printf.printf "Dataserver received the %s signal... killing\n%!" (Signal.to_string s);
Watchdog.kill (); Watchdog.kill ();
in in
List.iter [ List.iter [
Signal.int ;
Signal.term ; Signal.term ;
Signal.quit ; Signal.quit ;
Signal.int
] ]
~f:(fun x -> Signal.Expert.handle x handler) ~f:(fun x -> Signal.Expert.handle x handler)
; ;

View File

@ -71,6 +71,7 @@ let run ezfio_filename dataserver =
let terminate () = let terminate () =
(* Clean up the temp directory *) (* Clean up the temp directory *)
Watchdog.kill ();
Unix.chdir Qmcchem_config.dev_shm; Unix.chdir Qmcchem_config.dev_shm;
let command = let command =
Printf.sprintf "rm -rf -- \"%s\" " tmpdir Printf.sprintf "rm -rf -- \"%s\" " tmpdir
@ -96,14 +97,13 @@ let run ezfio_filename dataserver =
(* Signal handler to Kill properly all the processes *) (* Signal handler to Kill properly all the processes *)
let handler s = let handler s =
Printf.printf "Forwarder received the %s signal... killing\n" (Signal.to_string s); Printf.printf "Forwarder received the %s signal... killing\n%!" (Signal.to_string s);
terminate (); terminate ();
Watchdog.kill ();
in in
List.iter [ List.iter [
Signal.int ;
Signal.term ; Signal.term ;
Signal.quit ; Signal.quit ;
Signal.int
] ]
~f:(fun x -> Signal.Expert.handle x handler) ~f:(fun x -> Signal.Expert.handle x handler)
; ;

View File

@ -7,8 +7,8 @@ let full_run ?(start_dataserver=true) ezfio_filename =
and scheduler = and scheduler =
Scheduler.find () Scheduler.find ()
in in
Printf.printf "Scheduler : %s\n" (Scheduler.to_string scheduler); Printf.printf "Scheduler : %s\n%!" (Scheduler.to_string scheduler);
Printf.printf "Launcher : %s\n" (Launcher.to_string launcher ); Printf.printf "Launcher : %s\n%!" (Launcher.to_string launcher );
(* Create the node file *) (* Create the node file *)
@ -147,13 +147,13 @@ let run a d ?q ?s ezfio_filename =
(* Signal handler to Kill properly all the processes *) (* Signal handler to Kill properly all the processes *)
let handler s = let handler s =
Printf.printf "Received the %s signal... killing\n" (Signal.to_string s); Printf.printf "QMC=Chem received the %s signal... killing\n%!" (Signal.to_string s);
Watchdog.kill (); Watchdog.kill ();
in in
List.iter [ List.iter [
Signal.int ;
Signal.term ; Signal.term ;
Signal.quit ; Signal.quit ;
Signal.int
] ]
~f:(fun x -> Signal.Expert.handle x handler) ~f:(fun x -> Signal.Expert.handle x handler)
; ;

View File

@ -8,7 +8,7 @@ let _threads = ref [] ;;
let kill () = let kill () =
let kill pid = let kill pid =
Signal.send_i Signal.int (`Pid pid); Signal.send_i Signal.int (`Pid pid);
Printf.printf "Killed %d\n" (Pid.to_int pid) Printf.printf "Killed %d\n%!" (Pid.to_int pid)
in in
List.iter ~f:kill (!_list); List.iter ~f:kill (!_list);
exit 1 exit 1