OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 33 of file TestProcessSignalHandler.cpp.

References shutdown_callbacks_.

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

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

+ Here is the caller graph for this function:

void TestProcessSignalHandler::registerSignalHandler ( )
static

Definition at line 24 of file TestProcessSignalHandler.cpp.

References has_registered_signal_handler_, and shutdownSubsystemsAndExit().

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

24  {
26  std::signal(SIGTERM, shutdownSubsystemsAndExit);
27  std::signal(SIGSEGV, shutdownSubsystemsAndExit);
28  std::signal(SIGABRT, shutdownSubsystemsAndExit);
30  }
31 }
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 38 of file TestProcessSignalHandler.cpp.

References logger::shutdown(), and shutdown_callbacks_.

Referenced by registerSignalHandler().

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