Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SignalHandler.h
Go to the documentation of this file.
1#pragma once
2
3#include <unistd.h>
4#include <cstdint>
5#include <cstdlib>
6
7#include "storm-config.h"
9
10namespace storm {
11namespace utility {
12namespace resources {
13
18inline void quickest_exit(int errorCode) {
19#if defined LINUX
20 std::quick_exit(errorCode);
21#elif defined MACOS
22 std::_Exit(errorCode);
23#else
24 std::abort();
25#endif
26}
27
32inline void setTimeoutAlarm(uint_fast64_t timeout) {
33 alarm(timeout);
34}
35
37 public:
38 // Explicitly delete copy constructor
40
41 // Explicitly delete copy constructor
42 void operator=(SignalInformation const&) = delete;
43
49 static SignalInformation& infos();
50
56 inline bool isTerminate() const {
57 return terminate;
58 }
59
65 inline void setTerminate(bool terminate) {
66 this->terminate = terminate;
67 }
68
74 inline int getErrorCode() const {
75 return lastSignal;
76 }
77
82 inline void setErrorCode(int errorCode) {
83 lastSignal = errorCode;
84 }
85
86 private:
92
96 virtual ~SignalInformation();
97
98 // Flag whether the program should terminate
99 bool terminate;
100 // Store last signal code
101 int lastSignal;
102};
103
104inline void resetTimeoutAlarm() {
106 alarm(0);
107}
108
114inline bool isTerminate() {
116}
117
121void installSignalHandler(int maximalWaitTime);
122
123} // namespace resources
124} // namespace utility
125} // namespace storm
void setErrorCode(int errorCode)
Set the error code.
int getErrorCode() const
Get the error code.
SignalInformation(SignalInformation const &)=delete
void operator=(SignalInformation const &)=delete
static SignalInformation & infos()
Retrieves the only existing instance of the signal information.
bool isTerminate() const
Check whether the program should terminate (due to some abort signal).
void setTerminate(bool terminate)
Set whether the program should terminate.
void quickest_exit(int errorCode)
Exit without cleanup.
void setTimeoutAlarm(uint_fast64_t timeout)
Set timeout by raising an alarm after timeout seconds.
bool isTerminate()
Check whether the program should terminate (due to some abort signal).
void installSignalHandler(int maximalWaitTime)
Register some signal handlers to detect and correctly handle abortion (due to timeout for example).