blob: da4d4b0c0e6a192f862aa8f4fe3c299fe1d243e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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 */
|