30namespace G4HadSignalHandler_local
35 static void (*G4HadSignalHandler_initial)(int);
41G4ThreadLocal std::vector<sighandler_t> *G4HadSignalHandler::theCache = 0;
44G4HadSignalHandler::G4HadSignalHandler(sighandler_t aNew)
46 if (!theCache) theCache =
new std::vector<sighandler_t>;
49 G4HadSignalHandler_local::G4HadSignalHandler_initial =
50 signal(SIGSEGV, G4HadSignalHandler_local::HandleIt);
53 theCache->push_back(aNew);
56G4HadSignalHandler::~G4HadSignalHandler()
59 signal (SIGSEGV, G4HadSignalHandler_local::G4HadSignalHandler_initial);
63void G4HadSignalHandler_local::HandleIt(
int i)
69 *iii_p = G4HadSignalHandler::theCache->size()-1 ;
72 for(
int c=iii; c!=-1; c--)
76 (G4HadSignalHandler::theCache->operator[](c))(i);
79 std::cerr <<
"callback to user-defined or default signal handler"<<endl;
80 signal (SIGSEGV, G4HadSignalHandler_local::G4HadSignalHandler_initial);