crooks

combinatorial rooks
git clone https://a3nm.net/git/crooks/
Log | Files | Refs

commit b5fb0538080d7eea690fd5775ba206bf9f844c16
parent 8729df936060e870fdda89e0242179fc5ef6707d
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Sat,  7 Jun 2014 19:25:21 +0200

catch SIGINT to profile

Diffstat:
main.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/main.c b/main.c @@ -1,3 +1,4 @@ +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <time.h> @@ -47,6 +48,12 @@ unsigned char R[MAXN*MAXN][3]; // other rooks) for each cell (no matter whether it contains a rook or not) unsigned char V[MAXN][MAXN][MAXN]; +void intHandler() { + // needed for profiling + printf("SIGINT caught, exiting\n"); + exit(1); +} + void print() { // print the current grid and also rook positions when debug for (int x = 0; x < N; x++) { @@ -410,6 +417,7 @@ int main(int argc, char **argv) { } printf("using random seed %d\n", seed); srand(seed); + signal(SIGINT, intHandler); int tot; for (K = oK; K < N*N; K++) {