summaryrefslogtreecommitdiff
path: root/src/main/util.cpp
diff options
context:
space:
mode:
authorMathias Preiner <mathias.preiner@gmail.com>2017-12-12 11:34:46 -0800
committerGitHub <noreply@github.com>2017-12-12 11:34:46 -0800
commit83d2279aaa79ce04aa35b394b5063c6d59ff3ac1 (patch)
tree49b16f694611b9fea3324ebe6c30879e9ba7b16f /src/main/util.cpp
parentdc0dd5e34f9b2fe1ef79602cc2a5f3deeb7d684a (diff)
Add SIGTERM handler. (#1440)
Print statistics if CVC4 gets a SIGTERM signal.
Diffstat (limited to 'src/main/util.cpp')
-rw-r--r--src/main/util.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/util.cpp b/src/main/util.cpp
index 110fc2c67..43c880a7f 100644
--- a/src/main/util.cpp
+++ b/src/main/util.cpp
@@ -77,6 +77,14 @@ void timeout_handler(int sig, siginfo_t* info, void*) {
abort();
}
+/** Handler for SIGTERM. */
+void sigterm_handler(int sig, siginfo_t* info, void*)
+{
+ safe_print(STDERR_FILENO, "CVC4 interrupted by SIGTERM.\n");
+ print_statistics();
+ abort();
+}
+
/** Handler for SIGINT, i.e., when the user hits control C. */
void sigint_handler(int sig, siginfo_t* info, void*) {
safe_print(STDERR_FILENO, "CVC4 interrupted by user.\n");
@@ -321,6 +329,15 @@ void cvc4_init() throw(Exception) {
}
#endif /* HAVE_SIGALTSTACK */
+ struct sigaction act5;
+ act5.sa_sigaction = sigterm_handler;
+ act5.sa_flags = SA_SIGINFO;
+ sigemptyset(&act5.sa_mask);
+ if (sigaction(SIGTERM, &act5, NULL))
+ {
+ throw Exception(string("sigaction(SIGTERM) failure: ") + strerror(errno));
+ }
+
#endif /* __WIN32__ */
set_unexpected(cvc4unexpected);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback