14
14
15
15
*/
16
16
17
+ #include < cstdlib>
18
+ #include < csignal>
19
+ #include < iostream>
20
+
17
21
#include < util/unicode.h>
22
+ #include < util/signal_exception.h>
18
23
19
24
#include " cbmc_parseoptions.h"
20
25
@@ -31,15 +36,50 @@ Function: main
31
36
\*******************************************************************/
32
37
33
38
#ifdef _MSC_VER
39
+ /*
40
+ //prospective Windows signal handling code
41
+ #include <windows.h>
42
+ BOOL WINAPI CCHandler(DWORD);
43
+ BOOL WINAPI kill_handler(DWORD dwType)
44
+ {
45
+ switch(dwType) {
46
+ case CTRL_C_EVENT:
47
+ case CTRL_BREAK_EVENT:
48
+ std::cerr << "signal caught" << std::endl;
49
+ exit(1);
50
+ break;
51
+ default:
52
+ break;
53
+ }
54
+ return TRUE;
55
+ }
56
+ */
34
57
int wmain (int argc, const wchar_t **argv_wide)
35
58
{
59
+ /*
60
+ if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)CCHandler,TRUE)) {
61
+ std::cerr << "Unable to install signal handler!" << std::endl;
62
+ return 243;
63
+ }
64
+ */
65
+
36
66
const char **argv=narrow_argv (argc, argv_wide);
37
67
cbmc_parseoptionst parseoptions (argc, argv);
38
68
return parseoptions.main ();
39
69
}
40
70
#else
71
+ // signal_exceptiont signal_exception;
72
+
73
+ void kill_handler (int s)
74
+ {
75
+ // std::cerr << "signal caught" << std::endl;
76
+ // exit(1);
77
+ throw signal_exceptiont (s);
78
+ }
79
+
41
80
int main (int argc, const char **argv)
42
81
{
82
+ signal (SIGINT,kill_handler);
43
83
cbmc_parseoptionst parseoptions (argc, argv);
44
84
return parseoptions.main ();
45
85
}
0 commit comments