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