Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarSignalHandler.hpp
blob: 6bb83811b683df25b485b9aea200ea26b3d91529 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#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;
};

}