diff options
author | Morgan Deters <mdeters@gmail.com> | 2009-11-18 22:02:11 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2009-11-18 22:02:11 +0000 |
commit | 394791604a62e19763a8a45328bc5177d91fabf9 (patch) | |
tree | 29027c84c0285da33bac6c5d1366635b9e4db1bc /src/main/util.cpp | |
parent | 477e97cd81afe4b86eea47e9abe6311fc22299fc (diff) |
work on exprs, driver, util
Diffstat (limited to 'src/main/util.cpp')
-rw-r--r-- | src/main/util.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/main/util.cpp b/src/main/util.cpp new file mode 100644 index 000000000..da4d4b0c0 --- /dev/null +++ b/src/main/util.cpp @@ -0,0 +1,44 @@ +#include <string> +#include <cstdio> +#include <cstdlib> +#include <cerrno> +#include <string.h> +#include <signal.h> + +#include "util/exception.h" +#include "config.h" + +using CVC4::Exception; +using namespace std; + +namespace CVC4 { +namespace Main { + +void sigint_handler(int sig, siginfo_t* info, void*) { + fprintf(stderr, "CVC4 interrupted by user.\n"); + exit(info->si_signo + 128); +} + +void segv_handler(int sig, siginfo_t* info, void*) { + fprintf(stderr, "CVC4 suffered a segfault.\n"); + exit(info->si_signo + 128); +} + +void cvc4_init() throw() { + struct sigaction act1; + act1.sa_sigaction = sigint_handler; + act1.sa_flags = SA_SIGINFO; + sigemptyset(&act1.sa_mask); + if(sigaction(SIGINT, &act1, NULL)) + throw new Exception(string("sigaction(SIGINT) failure: ") + strerror(errno)); + + struct sigaction act2; + act2.sa_sigaction = segv_handler; + act2.sa_flags = SA_SIGINFO; + sigemptyset(&act2.sa_mask); + if(sigaction(SIGSEGV, &act2, NULL)) + throw new Exception(string("sigaction(SIGSEGV) failure: ") + strerror(errno)); +} + +}/* CVC4::Main namespace */ +}/* CVC4 namespace */ |