OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TestProcessSignalHandler Class Reference

#include <TestProcessSignalHandler.h>

Static Public Member Functions

static void registerSignalHandler ()
 
static void addShutdownCallback (std::function< void()> shutdown_callback)
 

Static Private Member Functions

static void shutdownSubsystemsAndExit (int signal_number)
 

Static Private Attributes

static bool has_registered_signal_handler_ {false}
 
static std::vector
< std::function< void()> > 
shutdown_callbacks_ {}
 

Detailed Description

Definition at line 22 of file TestProcessSignalHandler.h.

Member Function Documentation

void TestProcessSignalHandler::addShutdownCallback ( std::function< void()>  shutdown_callback)
static

Definition at line 34 of file TestProcessSignalHandler.cpp.

References shutdown_callbacks_.

Referenced by anonymous_namespace{QueryRunner.cpp}::setup_signal_handler().

35  {
36  shutdown_callbacks_.emplace_back(shutdown_callback);
37 }
static std::vector< std::function< void()> > shutdown_callbacks_

+ Here is the caller graph for this function:

void TestProcessSignalHandler::registerSignalHandler ( )
static

Definition at line 25 of file TestProcessSignalHandler.cpp.

References has_registered_signal_handler_, and shutdownSubsystemsAndExit().

Referenced by anonymous_namespace{QueryRunner.cpp}::setup_signal_handler().

25  {
27  std::signal(SIGTERM, shutdownSubsystemsAndExit);
28  std::signal(SIGSEGV, shutdownSubsystemsAndExit);
29  std::signal(SIGABRT, shutdownSubsystemsAndExit);
31  }
32 }
static void shutdownSubsystemsAndExit(int signal_number)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TestProcessSignalHandler::shutdownSubsystemsAndExit ( int  signal_number)
staticprivate

Definition at line 39 of file TestProcessSignalHandler.cpp.

References logger::shutdown(), and shutdown_callbacks_.

Referenced by registerSignalHandler().

39  {
40  std::cerr << __func__ << ": Interrupt signal (" << signal_number << ") received."
41  << std::endl;
42 
43  // Perform additional shutdowns
44  for (auto& callback : shutdown_callbacks_) {
45  callback();
46  }
47 
48  // Shutdown logging force a flush
50 
51  // Terminate program
52  // TODO: Why convert SIGTERM to EXIT_SUCCESS?
53  int const exit_code = signal_number == SIGTERM ? EXIT_SUCCESS : signal_number;
54 #ifdef __APPLE__
55  std::exit(exit_code);
56 #else
57  std::quick_exit(exit_code);
58 #endif
59 }
void shutdown()
Definition: Logger.cpp:401
static std::vector< std::function< void()> > shutdown_callbacks_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool TestProcessSignalHandler::has_registered_signal_handler_ {false}
staticprivate

Definition at line 30 of file TestProcessSignalHandler.h.

Referenced by registerSignalHandler().

std::vector< std::function< void()> > TestProcessSignalHandler::shutdown_callbacks_ {}
staticprivate

Definition at line 31 of file TestProcessSignalHandler.h.

Referenced by addShutdownCallback(), and shutdownSubsystemsAndExit().


The documentation for this class was generated from the following files: