Caffe2 - C++ API
A deep learning, cross platform ML framework
signal_handler.h
1 #pragma once
2 
3 #if defined(__APPLE__)
4 #define CAFFE2_SUPPORTS_SIGNAL_HANDLER
5 #elif defined(__linux__) && !defined(CAFFE2_DISABLE_SIGNAL_HANDLERS)
6 #define CAFFE2_SUPPORTS_FATAL_SIGNAL_HANDLERS
7 #define CAFFE2_SUPPORTS_SIGNAL_HANDLER
8 #endif
9 
10 namespace caffe2 {
11 
13  public:
14  enum class Action {
15  NONE,
16  STOP
17  };
18 
19  // Contructor. Specify what action to take when a signal is received.
20  SignalHandler(Action SIGINT_action,
21  Action SIGHUP_action);
22  ~SignalHandler();
23 
24  Action CheckForSignals();
25 
26  private:
27  bool GotSIGINT();
28  bool GotSIGHUP();
29  Action SIGINT_action_;
30  Action SIGHUP_action_;
31  unsigned long my_sigint_count_;
32  unsigned long my_sighup_count_;
33 };
34 
35 #if defined(CAFFE2_SUPPORTS_FATAL_SIGNAL_HANDLERS)
36 // This works by setting up certain fatal signal handlers. Previous fatal
37 // signal handlers will still be called when the signal is raised. Defaults
38 // to being off.
39 void setPrintStackTracesOnFatalSignal(bool print);
40 bool printStackTracesOnFatalSignal();
41 #endif // defined(CAFFE2_SUPPORTS_SIGNAL_HANDLER)
42 
43 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...