Skip to content

Commit

Permalink
Move the SIGINT handler to processXMLElement, duplicate for the two o…
Browse files Browse the repository at this point in the history
…verloads
  • Loading branch information
jmcarcell committed Jul 22, 2024
1 parent 2d2bf5b commit cbe295e
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions DDCore/src/DetectorLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ DetectorLoad::~DetectorLoad() {
/// Process XML unit and adopt all data from source structure.
void DetectorLoad::processXML(const std::string& xmlfile, xml::UriReader* entity_resolver) {

// 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);

try {
xml::DocumentHolder doc(xml::DocumentHandler().load(xmlfile,entity_resolver));
if ( doc ) {
Expand Down Expand Up @@ -143,6 +131,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";
Expand All @@ -167,6 +168,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";
Expand Down

0 comments on commit cbe295e

Please sign in to comment.