From 5025303e183b8a5887d3f6ec56da76786d6cecbe Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Sat, 23 Jan 2021 15:26:00 +0100 Subject: [PATCH] SIGINT handler, for partial result. --- best.c | 16 +++++++++++++++- eval.c | 4 ++++ lceb.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/best.c b/best.c index f5751c3..f96bb72 100644 --- a/best.c +++ b/best.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "lceb.h" static int target=0; @@ -12,13 +13,26 @@ static int bestops=MAXINT; static BEST bests[1024*10]; /* TODO: should be dynamic */ static int nbests=0; +static int sigint=0; #define DIFF(a, b) ((a)>(b)?(a)-(b):(b)-(a)) +void stopall() +{ + printf("SIGINT RECEIVED: aborting eval\n"); + sigint=1; +} + +int stopped() +{ + return sigint; +} + void set_target(n) int n; { target=n; + signal(SIGINT, stopall); } int check_best(res, nops, node, values, ops) @@ -104,7 +118,7 @@ void print_bests() for (i=0; i