feat(main): catch ctrl-c to cleanup

this allows us to cleanup progress bar, print stats, finish tracing,
etc.
This commit is contained in:
Simon Cruanes 2022-02-17 21:19:19 -05:00
parent 52cae96ee2
commit f26d178380
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -219,6 +219,7 @@ let main_cnf () : _ result =
r r
let main () = let main () =
Sys.catch_break true;
(* instrumentation and tracing *) (* instrumentation and tracing *)
Sidekick_tef.with_setup @@ fun () -> Sidekick_tef.with_setup @@ fun () ->
@ -278,6 +279,9 @@ let () = match main() with
| Invalid_argument e -> | Invalid_argument e ->
Format.printf "invalid argument:\n%s@." e; Format.printf "invalid argument:\n%s@." e;
exit_ 127 exit_ 127
| Sys.Break ->
Printf.printf "interrupted.\n%!";
exit_ 1;
| _ -> raise e | _ -> raise e
end end