Windows: Disabled signal handlers in logging.cpp for Windows systems.

The functionality in glog is not supported with Windows.

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


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

Branch: refs/heads/master
Commit: 7d775569b36b43dba8be34b61f4198f61a587e8a
Parents: 7737edf
Author: Daniel Pravat <[email protected]>
Authored: Mon May 30 17:56:48 2016 -0700
Committer: Joris Van Remoortere <[email protected]>
Committed: Mon May 30 17:57:54 2016 -0700

----------------------------------------------------------------------
 src/logging/logging.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7d775569/src/logging/logging.cpp
----------------------------------------------------------------------
diff --git a/src/logging/logging.cpp b/src/logging/logging.cpp
index 20d2f63..7ea1899 100644
--- a/src/logging/logging.cpp
+++ b/src/logging/logging.cpp
@@ -31,7 +31,9 @@
 #include <stout/stringify.hpp>
 #include <stout/try.hpp>
 
+#ifndef __WINDOWS__
 #include <stout/os/signals.hpp>
+#endif // __WINDOWS__
 
 #include "logging/logging.hpp"
 
@@ -78,6 +80,7 @@ string argv0;
 // allocate any memory or grab locks. And according to
 // https://code.google.com/p/google-glog/issues/detail?id=161
 // it should work in 'most' cases in signal handlers.
+#ifndef __WINDOWS__
 inline void handler(int signal, siginfo_t *siginfo, void *context)
 {
   if (signal == SIGTERM) {
@@ -98,7 +101,7 @@ inline void handler(int signal, siginfo_t *siginfo, void 
*context)
     RAW_LOG(FATAL, "Unexpected signal in signal handler: %d", signal);
   }
 }
-
+#endif // __WINDOWS__
 
 google::LogSeverity getLogSeverity(const string& logging_level)
 {
@@ -196,10 +199,18 @@ void initialize(
     (flags.log_dir.isSome() ? flags.log_dir.get() : "STDERR");
 
   if (installFailureSignalHandler) {
+    // glog on Windows does not support `InstallFailureSignalHandler`.
+#ifndef __WINDOWS__
     // Handles SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, SIGTERM
     // by default.
     google::InstallFailureSignalHandler();
 
+    // The code below sets the SIGTERM signal handler to the `handle` function
+    // declared above. While this is useful on POSIX systems, SIGTERM is
+    // generated and handled differently on Windows[1], so this code would
+    // not work.
+    // [1] https://msdn.microsoft.com/en-us/library/xdkz3x12.aspx
+
     // Set up our custom signal handlers.
     struct sigaction action;
     action.sa_sigaction = handler;
@@ -217,6 +228,7 @@ void initialize(
     if (sigaction(SIGTERM, &action, NULL) < 0) {
       PLOG(FATAL) << "Failed to set sigaction";
     }
+#endif // __WINDOWS__
   }
 
   initialized->done();

Reply via email to