Repositories / agent-snapshot.git
agent-snapshot.git
Clone (read-only): git clone http://git.guha-anderson.com/git/agent-snapshot.git
@@ -837,6 +837,19 @@ let restore_snapshot (dir : string) : unit = | _ -> ()) files +let install_shutdown_sigint_handler () : unit = + let count = ref 0 in + Sys.set_signal Sys.sigint + (Sys.Signal_handle + (fun _ -> + incr count; + if !count >= 2 then ( + Sys.set_signal Sys.sigint Sys.Signal_default; + Unix.kill (Unix.getpid ()) Sys.sigint) + else ( + prerr_endline "Press Ctrl+C again to terminate the snapshot"; + flush stderr))) + let run_snapshot (output : string option) (command : string list) : int = load_ignore_config (); let output = @@ -850,6 +863,7 @@ let run_snapshot (output : string option) (command : string list) : int = mkdir_p output; with_blob_row_group_writer (fun () -> trace_command command; + install_shutdown_sigint_handler (); finalize_records (); close_blob_writer ()); write_manifest output command 0;