Import PicoSAT-965
[cl-satwrap.git] / backends / picosat / main.c
blob1259c993ee55a40b0af17aa818adf739a37f00c6
1 <<<<<<< HEAD
2 #include <signal.h>
3 #include <stdlib.h>
4 #include <string.h>
6 #include "picosat.h"
8 int picosat_main (int, char **);
10 static int catched;
12 static void (*sig_int_handler);
13 static void (*sig_segv_handler);
14 static void (*sig_abrt_handler);
15 static void (*sig_term_handler);
16 #ifndef NALLSIGNALS
17 static void (*sig_kill_handler);
18 static void (*sig_xcpu_handler);
19 static void (*sig_xfsz_handler);
20 #endif
22 static void
23 resetsighandlers (void)
25 (void) signal (SIGINT, sig_int_handler);
26 (void) signal (SIGSEGV, sig_segv_handler);
27 (void) signal (SIGABRT, sig_abrt_handler);
28 (void) signal (SIGTERM, sig_term_handler);
29 #ifndef NALLSIGNALS
30 (void) signal (SIGKILL, sig_kill_handler);
31 (void) signal (SIGXCPU, sig_xcpu_handler);
32 (void) signal (SIGXFSZ, sig_xfsz_handler);
33 #endif
36 static void
37 message (int sig)
39 picosat_message (1, "");
40 picosat_message (1, "*** CAUGHT SIGNAL %d ***", sig);
41 picosat_message (1, "");
44 static void
45 catch (int sig)
47 if (!catched)
49 message (sig);
50 catched = 1;
51 picosat_stats ();
52 message (sig);
55 resetsighandlers ();
56 raise (sig);
59 static void
60 setsighandlers (void)
62 sig_int_handler = signal (SIGINT, catch);
63 sig_segv_handler = signal (SIGSEGV, catch);
64 sig_abrt_handler = signal (SIGABRT, catch);
65 sig_term_handler = signal (SIGTERM, catch);
66 #ifndef NALLSIGNALS
67 sig_kill_handler = signal (SIGKILL, catch);
68 sig_xcpu_handler = signal (SIGXCPU, catch);
69 sig_xfsz_handler = signal (SIGXFSZ, catch);
70 #endif
73 int
74 main (int argc, char **argv)
76 int res, verbose;
78 for (verbose = argc - 1; verbose; verbose--)
79 if (!strcmp (argv[verbose], "-v"))
80 break;
82 if (verbose)
83 setsighandlers ();
85 res = picosat_main (argc, argv);
87 if (verbose)
88 resetsighandlers ();
90 return res;
91 =======
92 int picosat_main (int, char **);
94 int
95 main (int argc, char **argv)
97 return picosat_main (argc, argv);
98 >>>>>>> 7a0fcd7... Import PicoSAT-965