[sheepdog] [PATCH] call a default signal handler in crash_handler()
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Fri Apr 12 06:58:49 CEST 2013
This makes the process dump a core file.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
collie/collie.c | 12 ++++++++++++
lib/logger.c | 8 ++++++++
lib/util.c | 2 +-
sheep/sheep.c | 6 ++++++
4 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/collie/collie.c b/collie/collie.c
index 2394350..c15071a 100644
--- a/collie/collie.c
+++ b/collie/collie.c
@@ -320,6 +320,18 @@ static void crash_handler(int signo)
sd_backtrace();
+ /*
+ * OOM raises SIGABRT in xmalloc but the administrator expects
+ * that collie exits with EXIT_SYSFAIL. We have to give up
+ * dumping a core file in this case.
+ */
+ if (signo != SIGABRT) {
+ raise(signo);
+
+ fprintf(stderr, "signal (%s) didn't terminate the process.",
+ strsignal(signo));
+ }
+
exit(EXIT_SYSFAIL);
}
diff --git a/lib/logger.c b/lib/logger.c
index a31cb1f..d435a74 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -489,6 +489,14 @@ static notrace void crash_handler(int signo)
log_flush();
closelog();
free_logarea();
+
+ if (signo != SIGHUP) {
+ raise(signo);
+
+ sd_printf(SDOG_EMERG,
+ "signal (%s) didn't terminate the process.",
+ strsignal(signo));
+ }
exit(1);
}
diff --git a/lib/util.c b/lib/util.c
index 39779a5..b5f005f 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -380,7 +380,7 @@ int install_sighandler(int signum, void (*handler)(int), bool once)
sa.sa_handler = handler;
if (once)
- sa.sa_flags = SA_RESETHAND;
+ sa.sa_flags = SA_RESETHAND | SA_NODEFER;
sigemptyset(&sa.sa_mask);
return sigaction(signum, &sa, NULL);
diff --git a/sheep/sheep.c b/sheep/sheep.c
index cda8493..6520a2c 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -182,6 +182,12 @@ static void crash_handler(int signo)
sd_backtrace();
sd_dump_variable(__sys);
+
+ raise(signo);
+
+ sd_printf(SDOG_EMERG, "signal (%s) didn't terminate the process.",
+ strsignal(signo));
+ exit(1);
}
static struct cluster_info __sys;
--
1.8.1.3.566.gaa39828
More information about the sheepdog
mailing list