diff --git a/src/storm.cpp b/src/storm.cpp index 6614172b5..207415e31 100644 --- a/src/storm.cpp +++ b/src/storm.cpp @@ -385,9 +385,9 @@ void checkPrctlFormulae(storm::modelchecker::prctl::AbstractModelChecker * Main entry point. */ int main(const int argc, const char* argv[]) { - // Register a signal handler to catch segfaults and display a backtrace. + // Register a signal handler to catch signals and display a backtrace. installSignalHandler(); - + // Print an information header. printHeader(argc, argv); diff --git a/src/utility/ErrorHandling.h b/src/utility/ErrorHandling.h index 4c87f4d0a..eb06b0afd 100644 --- a/src/utility/ErrorHandling.h +++ b/src/utility/ErrorHandling.h @@ -121,10 +121,30 @@ void signalHandler(int sig) { * Registers some signal handlers so that we can display a backtrace upon erroneuous termination. */ void installSignalHandler() { +#ifndef WINDOWS + struct sigaction sa; + sa.sa_handler = signalHandler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + + if (sigaction(SIGSEGV, &sa, nullptr) == -1) { + std::cerr << "FATAL: Installing a signal handler failed." << std::endl; + } + if (sigaction(SIGABRT, &sa, nullptr) == -1) { + std::cerr << "FATAL: Installing a signal handler failed." << std::endl; + } + if (sigaction(SIGINT, &sa, nullptr) == -1) { + std::cerr << "FATAL: Installing a signal handler failed." << std::endl; + } + if (sigaction(SIGTERM, &sa, nullptr) == -1) { + std::cerr << "FATAL: Installing a signal handler failed." << std::endl; + } +#else signal(SIGSEGV, signalHandler); signal(SIGABRT, signalHandler); signal(SIGINT, signalHandler); signal(SIGTERM, signalHandler); +#endif } #endif /* ERRORHANDLING_H */