osb/source/core/StarSignalHandler.hpp

35 lines
827 B
C++
Raw Permalink Normal View History

#pragma once
2023-06-20 04:33:09 +00:00
#include "StarException.hpp"
namespace Star {
STAR_STRUCT(SignalHandlerImpl);
// Singleton signal handler that registers handlers for segfault, fpe,
// illegal instructions etc as well as non-fatal interrupts.
class SignalHandler {
public:
SignalHandler();
~SignalHandler();
// If enabled, will catch segfault, fpe, and illegal instructions and output
// error information before dying.
void setHandleFatal(bool handleFatal);
bool handlingFatal() const;
// If enabled, non-fatal interrupt signal will be caught and will not kill
// the process and will instead set the interrupted flag.
void setHandleInterrupt(bool handleInterrupt);
bool handlingInterrupt() const;
bool interruptCaught() const;
private:
friend SignalHandlerImpl;
static SignalHandlerImplUPtr s_singleton;
};
}