#include <stdio.h>
#include <stdbool.h>
#include <getopt.h>
+#include <signal.h>
#include "main.h"
#include "misc.h"
extern void score(long);
extern int action(FILE *, long);
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ if (logfp != NULL)
+ fflush(logfp);
+ exit(0);
+}
+
/*
* MAIN PROGRAM
*/
fprintf(stderr,
"advent: can't open logfile %s for write\n",
optarg);
+ signal(SIGINT, sig_handler);
break;
case 'o':
oldstyle = true;