using namespace CVC4::main;
static Result lastResult;
-static struct Options options;
+
+namespace CVC4 {
+ namespace main {
+ struct Options options;
+ }/* CVC4::main namespace */
+}/* CVC4 namespace */
int runCvc4(int argc, char* argv[]);
void doCommand(SmtEngine&, Command*);
*/
extern bool segvNoSpin;
+/**
+ * Keep a copy of the options around globally, so that signal handlers can
+ * access it.
+ */
+extern struct Options options;
+
/** Parse argc/argv and put the result into a CVC4::Options struct. */
int parseOptions(int argc, char** argv, CVC4::Options*) throw(OptionException);
#include <signal.h>
#include "util/exception.h"
+#include "util/options.h"
#include "util/Assert.h"
+#include "util/stats.h"
#include "cvc4autoconfig.h"
#include "main.h"
*/
bool segvNoSpin = false;
+/** Handler for SIGXCPU, i.e., timeout. */
+void timeout_handler(int sig, siginfo_t* info, void*) {
+ fprintf(stderr, "CVC4 interrupted by timeout.\n");
+ if(options.statistics) {
+ StatisticsRegistry::flushStatistics(cerr);
+ }
+ abort();
+}
+
/** Handler for SIGINT, i.e., when the user hits control C. */
void sigint_handler(int sig, siginfo_t* info, void*) {
fprintf(stderr, "CVC4 interrupted by user.\n");
+ if(options.statistics) {
+ StatisticsRegistry::flushStatistics(cerr);
+ }
abort();
}
throw Exception(string("sigaction(SIGINT) failure: ") + strerror(errno));
struct sigaction act2;
- act2.sa_sigaction = segv_handler;
+ act2.sa_sigaction = timeout_handler;
act2.sa_flags = SA_SIGINFO;
sigemptyset(&act2.sa_mask);
- if(sigaction(SIGSEGV, &act2, NULL))
+ if(sigaction(SIGXCPU, &act2, NULL))
+ throw Exception(string("sigaction(SIGXCPU) failure: ") + strerror(errno));
+
+ struct sigaction act3;
+ act3.sa_sigaction = segv_handler;
+ act3.sa_flags = SA_SIGINFO;
+ sigemptyset(&act3.sa_mask);
+ if(sigaction(SIGSEGV, &act3, NULL))
throw Exception(string("sigaction(SIGSEGV) failure: ") + strerror(errno));
set_unexpected(cvc4unexpected);