diff options
author | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2011-01-21 14:45:01 +0100 |
---|---|---|
committer | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2011-01-21 15:47:05 +0100 |
commit | ba000d9c27ab9f767c574a11cf8a5d8ac0fad65c (patch) | |
tree | b7888e77537d3d35a95e9ce665c65d50abc31d77 | |
parent | msgr: always start reaper (diff) | |
download | ceph-ba000d9c27ab9f767c574a11cf8a5d8ac0fad65c.tar.xz ceph-ba000d9c27ab9f767c574a11cf8a5d8ac0fad65c.zip |
common: add signal_mask_to_str
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
-rw-r--r-- | src/common/signal.cc | 23 | ||||
-rw-r--r-- | src/common/signal.h | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/common/signal.cc b/src/common/signal.cc index 626b48b6525..1548f48565a 100644 --- a/src/common/signal.cc +++ b/src/common/signal.cc @@ -17,6 +17,7 @@ #include "common/debug.h" #include <signal.h> +#include <sstream> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> @@ -78,6 +79,28 @@ static void handle_fatal_signal(int signum) exit(1); } +#include <syslog.h> + +std::string signal_mask_to_str() +{ + sigset_t old_sigset; + if (pthread_sigmask(SIG_SETMASK, NULL, &old_sigset)) { + return "(pthread_signmask failed)"; + } + + ostringstream oss; + oss << "show_signal_mask: { "; + string sep(""); + for (int signum = 0; signum < NSIG; ++signum) { + if (sigismember(&old_sigset, signum) == 1) { + oss << sep << signum; + sep = ", "; + } + } + oss << " }"; + return oss.str(); +} + void install_standard_sighandlers(void) { install_sighandler(SIGHUP, sighup_handler, SA_RESTART); diff --git a/src/common/signal.h b/src/common/signal.h index a58fcd7a1d6..6364cc40675 100644 --- a/src/common/signal.h +++ b/src/common/signal.h @@ -17,4 +17,6 @@ void install_standard_sighandlers(void); +std::string signal_mask_to_str(); + #endif |