Browse Source

Moved to new sigaction API to more reliably catch signals.

Former-commit-id: 3ebe52109e
tempestpy_adaptions
dehnert 11 years ago
parent
commit
55187c3350
  1. 4
      src/storm.cpp
  2. 20
      src/utility/ErrorHandling.h

4
src/storm.cpp

@ -385,9 +385,9 @@ void checkPrctlFormulae(storm::modelchecker::prctl::AbstractModelChecker<double>
* 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);

20
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 */

Loading…
Cancel
Save