Skip to content

Commit

Permalink
Merge pull request #12856 from Dr15Jones/addSigTermHandling
Browse files Browse the repository at this point in the history
Have SIGTERM print a traceback
  • Loading branch information
davidlange6 committed Dec 30, 2015
2 parents 9ae5e58 + 9b271b4 commit be91645
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
39 changes: 28 additions & 11 deletions FWCore/Services/src/InitRootHandlers.cc
Expand Up @@ -295,15 +295,27 @@ namespace {
const char* signalname = "unknown";
switch (sig) {
case SIGBUS:
signalname = "bus error";
break;
case SIGSEGV:
signalname = "segmentation violation";
break;
case SIGILL:
signalname = "illegal instruction";
default:
break;
{
signalname = "bus error";
break;
}
case SIGSEGV:
{
signalname = "segmentation violation";
break;
}
case SIGILL:
{
signalname = "illegal instruction";
break;
}
case SIGTERM:
{
signalname = "external termination request";
break;
}
default:
break;
}
full_cerr_write("\n\nA fatal system signal has occurred: ");
full_cerr_write(signalname);
Expand All @@ -316,9 +328,9 @@ namespace {
full_cerr_write(signalname);
full_cerr_write("\n");

// For these three known cases, re-raise the signal so get the correct
// For these four known cases, re-raise the signal so get the correct
// exit code.
if ((sig == SIGILL) || (sig == SIGSEGV) || (sig == SIGBUS))
if ((sig == SIGILL) || (sig == SIGSEGV) || (sig == SIGBUS) || (sig == SIGTERM))
{
signal(sig, SIG_DFL);
raise(sig);
Expand All @@ -338,6 +350,7 @@ namespace {
signal(SIGILL, SIG_DFL);
signal(SIGSEGV, SIG_DFL);
signal(SIGBUS, SIG_DFL);
signal(SIGTERM, SIG_DFL);
}

} // end of unnamed namespace
Expand Down Expand Up @@ -528,6 +541,10 @@ namespace edm {
sigIllHandler_ = std::shared_ptr<const void>(nullptr,[](void*) {
installCustomHandler(SIGILL,sig_abort);
});
installCustomHandler(SIGTERM,sig_dostack_then_abort);
sigTermHandler_ = std::shared_ptr<const void>(nullptr,[](void*) {
installCustomHandler(SIGTERM,sig_abort);
});
iReg.watchPostForkReacquireResources(this, &InitRootHandlers::cachePidInfoHandler);
}

Expand Down
1 change: 1 addition & 0 deletions FWCore/Services/src/InitRootHandlers.h
Expand Up @@ -49,6 +49,7 @@ namespace edm {
std::shared_ptr<const void> sigBusHandler_;
std::shared_ptr<const void> sigSegvHandler_;
std::shared_ptr<const void> sigIllHandler_;
std::shared_ptr<const void> sigTermHandler_;
};

inline
Expand Down

0 comments on commit be91645

Please sign in to comment.