From 0f5a2b66c183e43062956e2e10f570ae4a6e01a8 Mon Sep 17 00:00:00 2001
From: Erwan Jahier <erwan.jahier@univ-grenoble-alpes.fr>
Date: Mon, 27 Feb 2023 15:29:05 +0100
Subject: [PATCH] fix: try to catch ctrc-c signals (do not seem to work)

---
 lib/sasacore/localSearch.ml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/sasacore/localSearch.ml b/lib/sasacore/localSearch.ml
index 133cb615..6d0933ed 100644
--- a/lib/sasacore/localSearch.ml
+++ b/lib/sasacore/localSearch.ml
@@ -37,6 +37,7 @@ let (run : ('n, 'tv, 'v) t -> 'n option -> 'n sol) =
   let pre_process sol_opt (v, tv) n =
     if visited n v || cut sol_opt n then (v, tv) else (g.visiting n v, g.push tv n)
   in
+  Sys.catch_break true;
   let rec loop ps n tv v psol =
    let do_succ_cont s =
      if g.stop ps n then Stopped else loop2 n tv v s
@@ -54,7 +55,10 @@ let (run : ('n, 'tv, 'v) t -> 'n option -> 'n sol) =
     )
   in
   let n, tv, v = g.init in
-  loop n n tv v pre_sol
+  try loop n n tv v pre_sol
+  with Stdlib.Sys.Break ->
+    Printf.printf  "The search has been interrupted by CTRL-C\n%!";
+    Stopped
 
 let stat log =
   Printf.fprintf log "
-- 
GitLab