handle sigint

This commit is contained in:
Mylloon 2023-05-15 11:02:56 +02:00
parent 25f1d808e9
commit d5a7c3d0ed
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -28,8 +28,17 @@ let main ctx =
login_twitter ctx username password (Sys.getenv_opt "TWITTER_TOTP") login_twitter ctx username password (Sys.getenv_opt "TWITTER_TOTP")
;; ;;
let handler data (signal : int) =
stop_process data;
exit
(match signal with
| v when v = Sys.sigint -> 130
| _ -> 1)
;;
let () = let () =
let data = start (Gecko "0.33.0") in let data = start (Gecko "0.33.0") in
Sys.set_signal Sys.sigint (Sys.Signal_handle (handler (fst data)));
let ctx = { session_id = snd data } in let ctx = { session_id = snd data } in
(try main ctx with (try main ctx with
| Any why -> print_endline why); | Any why -> print_endline why);