From d5a7c3d0ed738e04ff82ab5844b64f9668eb0059 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 15 May 2023 11:02:56 +0200 Subject: [PATCH] handle sigint --- bin/main.ml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/main.ml b/bin/main.ml index f1fa0d1..d773602 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -28,8 +28,17 @@ let main ctx = 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 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 (try main ctx with | Any why -> print_endline why);