SIGINT handler, for partial result.

This commit is contained in:
2021-01-23 15:26:00 +01:00
parent 0931d679fa
commit 5025303e18
3 changed files with 20 additions and 1 deletions

16
best.c
View File

@@ -3,6 +3,7 @@
#include <string.h>
#include <malloc.h>
#include <values.h>
#include <signal.h>
#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<nbests; ++i) {
//print_best(bests[i].root, bests[i].values, bests[i].oper, 0);
printf("%3d: %d = ", i, bests[i].res);
print_node(bests[i].root, TREE_TOP, 0, 0);
print_node(bests[i].root, TREE_TOP, 0, 4);
putchar('\n');
//printf("%3d: %d = ", i, bests[i].res);
//print_node(bests[i].root, TREE_TOP, 0, 1);