Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
Catch::FatalConditionHandler Struct Reference

#include <catch_fatal_condition.h>

Collaboration diagram for Catch::FatalConditionHandler:

Public Member Functions

 FatalConditionHandler ()
 
 ~FatalConditionHandler ()
 

Static Public Member Functions

static void handleSignal (int sig)
 
static void reset ()
 

Static Public Attributes

static bool isSet = false
 
static struct sigaction oldSigActions [] = {}
 
static stack_t oldSigStack = {}
 
static char altStackMem [] = {}
 

Detailed Description

Definition at line 42 of file catch_fatal_condition.h.

Constructor & Destructor Documentation

◆ FatalConditionHandler()

Catch::FatalConditionHandler::FatalConditionHandler ( )

Definition at line 125 of file catch_fatal_condition.cpp.

125 {
126 isSet = true;
127 stack_t sigStack;
128 sigStack.ss_sp = altStackMem;
129 sigStack.ss_size = sigStackSize;
130 sigStack.ss_flags = 0;
131 sigaltstack(&sigStack, &oldSigStack);
132 struct sigaction sa = { };
133
134 sa.sa_handler = handleSignal;
135 sa.sa_flags = SA_ONSTACK;
136 for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) {
137 sigaction(signalDefs[i].id, &sa, &oldSigActions[i]);
138 }
139 }
static struct sigaction oldSigActions[]
Here is the call graph for this function:

◆ ~FatalConditionHandler()

Catch::FatalConditionHandler::~FatalConditionHandler ( )

Definition at line 142 of file catch_fatal_condition.cpp.

142 {
143 reset();
144 }
Here is the call graph for this function:

Member Function Documentation

◆ handleSignal()

void Catch::FatalConditionHandler::handleSignal ( int sig)
static

Definition at line 112 of file catch_fatal_condition.cpp.

112 {
113 char const * name = "<unknown signal>";
114 for (auto const& def : signalDefs) {
115 if (sig == def.id) {
116 name = def.name;
117 break;
118 }
119 }
120 reset();
121 reportFatal(name);
122 raise( sig );
123 }
std::string name
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void Catch::FatalConditionHandler::reset ( )
static

Definition at line 146 of file catch_fatal_condition.cpp.

146 {
147 if( isSet ) {
148 // Set signals back to previous values -- hopefully nobody overwrote them in the meantime
149 for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) {
150 sigaction(signalDefs[i].id, &oldSigActions[i], nullptr);
151 }
152 // Return the old stack
153 sigaltstack(&oldSigStack, nullptr);
154 isSet = false;
155 }
156 }
Here is the caller graph for this function:

Member Data Documentation

◆ altStackMem

char Catch::FatalConditionHandler::altStackMem = {}
static

Definition at line 47 of file catch_fatal_condition.h.

◆ isSet

bool Catch::FatalConditionHandler::isSet = false
static

Definition at line 44 of file catch_fatal_condition.h.

◆ oldSigActions

struct sigaction Catch::FatalConditionHandler::oldSigActions = {}
static

Definition at line 45 of file catch_fatal_condition.h.

◆ oldSigStack

stack_t Catch::FatalConditionHandler::oldSigStack = {}
static

Definition at line 46 of file catch_fatal_condition.h.


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