fixes to build structure, util classes, lots of fixes to Node and NodeBuilder. outst...
[cvc5.git] / src / main / util.cpp
1 /********************* -*- C++ -*- */
2 /** util.cpp
3 ** Original author: mdeters
4 ** Major contributors: none
5 ** Minor contributors (to current version): none
6 ** This file is part of the CVC4 prototype.
7 ** Copyright (c) 2009 The Analysis of Computer Systems Group (ACSys)
8 ** Courant Institute of Mathematical Sciences
9 ** New York University
10 ** See the file COPYING in the top-level source directory for licensing
11 ** information.
12 **
13 ** [[ Add file-specific comments here ]]
14 **/
15
16 #include <cstdio>
17 #include <cstdlib>
18 #include <cerrno>
19 #include <string.h>
20 #include <signal.h>
21
22 #include "util/exception.h"
23 #include "config.h"
24
25 using CVC4::Exception;
26 using namespace std;
27
28 namespace CVC4 {
29 namespace main {
30
31 // FIXME add comments to functions
32
33 void sigint_handler(int sig, siginfo_t* info, void*) {
34 fprintf(stderr, "CVC4 interrupted by user.\n");
35 abort();
36 }
37
38 void segv_handler(int sig, siginfo_t* info, void*) {
39 fprintf(stderr, "CVC4 suffered a segfault.\n");
40 abort();
41 }
42
43 void cvc4_init() throw() {
44 struct sigaction act1;
45 act1.sa_sigaction = sigint_handler;
46 act1.sa_flags = SA_SIGINFO;
47 sigemptyset(&act1.sa_mask);
48 if(sigaction(SIGINT, &act1, NULL))
49 throw Exception(string("sigaction(SIGINT) failure: ") + strerror(errno));
50
51 struct sigaction act2;
52 act2.sa_sigaction = segv_handler;
53 act2.sa_flags = SA_SIGINFO;
54 sigemptyset(&act2.sa_mask);
55 if(sigaction(SIGSEGV, &act2, NULL))
56 throw Exception(string("sigaction(SIGSEGV) failure: ") + strerror(errno));
57 }
58
59 }/* CVC4::main namespace */
60 }/* CVC4 namespace */