You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2013/07/30 02:03:06 UTC

git commit: Changed the SIGTERM handler to not dump a stacktrace.

Updated Branches:
  refs/heads/master e88b1bde4 -> 15400c229


Changed the SIGTERM handler to not dump a stacktrace.

Review: https://reviews.apache.org/r/13028


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/15400c22
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/15400c22
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/15400c22

Branch: refs/heads/master
Commit: 15400c2291e5747fc9fe78d5331e71175c2864e0
Parents: e88b1bd
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Mon Jul 29 12:23:06 2013 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Mon Jul 29 17:02:55 2013 -0700

----------------------------------------------------------------------
 src/logging/logging.cpp | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/15400c22/src/logging/logging.cpp
----------------------------------------------------------------------
diff --git a/src/logging/logging.cpp b/src/logging/logging.cpp
index 7386e5e..0282b1f 100644
--- a/src/logging/logging.cpp
+++ b/src/logging/logging.cpp
@@ -49,9 +49,15 @@ string argv0;
 
 void handler(int signal)
 {
-  LOG(WARNING) << "Received signal '" << strsignal(signal)
-               << "', escalating to SIGABRT";
-  raise(SIGABRT);
+  if (signal == SIGTERM) {
+    EXIT(1) << "Received signal SIGTERM; exiting.";
+  } else if (signal == SIGPIPE) {
+    LOG(WARNING) << "Received signal SIGPIPE; escalating to SIGABRT";
+    raise(SIGABRT);
+  } else {
+    LOG(FATAL) << "Unexpected signal in signal handler: '"
+               << strsignal(signal) << "'";
+  }
 }
 
 
@@ -96,9 +102,7 @@ void initialize(
     // by default.
     google::InstallFailureSignalHandler();
 
-    // Set up the SIGPIPE signal handler to escalate to SIGABRT
-    // in order to have the glog handler catch it and print all
-    // of its lovely information.
+    // Set up our custom signal handlers.
     struct sigaction action;
     action.sa_handler = handler;
 
@@ -106,9 +110,19 @@ void initialize(
     sigemptyset(&action.sa_mask);
     action.sa_flags = 0;
 
+    // Set up the SIGPIPE signal handler to escalate to SIGABRT
+    // in order to have the glog handler catch it and print all
+    // of its lovely information.
     if (sigaction(SIGPIPE, &action, NULL) < 0) {
       PLOG(FATAL) << "Failed to set sigaction";
     }
+
+    // We also do not want SIGTERM to dump a stacktrace, as this
+    // can imply that we crashed, when we were in fact terminated
+    // by user request.
+    if (sigaction(SIGTERM, &action, NULL) < 0) {
+      PLOG(FATAL) << "Failed to set sigaction";
+    }
   }
 
   initialized->done();