diff --git a/DDCore/src/DetectorLoad.cpp b/DDCore/src/DetectorLoad.cpp index cf464a4dd..35385f9b4 100644 --- a/DDCore/src/DetectorLoad.cpp +++ b/DDCore/src/DetectorLoad.cpp @@ -20,6 +20,9 @@ #include // C/C++ include files +#include +#include +#include #include #ifndef __TIXML__ @@ -127,6 +130,19 @@ void DetectorLoad::processXMLString(const char* xmldata, xml::UriReader* entity_ /// Process a given DOM (sub-) tree void DetectorLoad::processXMLElement(const std::string& xmlfile, const xml::Handle_t& xml_root) { + + // Install signal handler for SIGINT (Ctrl-C) + struct sigaction sigIntHandler; + + sigIntHandler.sa_handler = [](int) { + std::cerr << "Caught signal SIGINT, exiting..." << std::endl; + exit(1); + }; + sigemptyset(&sigIntHandler.sa_mask); + sigIntHandler.sa_flags = 0; + + sigaction(SIGINT, &sigIntHandler, NULL); + if ( xml_root.ptr() ) { std::string tag = xml_root.tag(); std::string type = tag + "_XML_reader"; @@ -151,6 +167,19 @@ void DetectorLoad::processXMLElement(const std::string& xmlfile, const xml::Hand /// Process a given DOM (sub-) tree void DetectorLoad::processXMLElement(const xml::Handle_t& xml_root, DetectorBuildType /* type */) { + + // Install signal handler for SIGINT (Ctrl-C) + struct sigaction sigIntHandler; + + sigIntHandler.sa_handler = [](int) { + std::cerr << "Caught signal SIGINT, exiting..." << std::endl; + exit(1); + }; + sigemptyset(&sigIntHandler.sa_mask); + sigIntHandler.sa_flags = 0; + + sigaction(SIGINT, &sigIntHandler, NULL); + if ( xml_root.ptr() ) { std::string tag = xml_root.tag(); std::string type = tag + "_XML_reader";