[sheepdog] [PATCH] call a default signal handler in crash_handler()

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri Apr 12 09:53:23 CEST 2013


At Fri, 12 Apr 2013 15:17:28 +0800,
Liu Yuan wrote:
> 
> On 04/12/2013 03:11 PM, MORITA Kazutaka wrote:
> > Do you mean crash_handler() in logger.c?  The re-raised signal will be
> > sent to itself (the logger process), so it doesn't terminate sheep.
> > The string should be "default handler for signal xxx didn't terminate
> > the logger process"?
> 
> All three crash_handler() will call exit finally, so why logger process
> isn't terminated by that exit()?

Hmm, I don't get your point.  The logger crash_handler works as same
as the sheep and collie crash_handler do.

--- 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);
 }        

signo!=SIGHUP means that the signal was raised because of the logger
problem.  Then, the crash_handler() re-raises the signal to dump a
core file and exit.  If something unexpected happens, the logger
process doesn't terminate in the default signal handler.  Then, the
logger notifies it to the user and exits in crash_handler.  If the
default handler works as expected, sd_printf and exit aren't called at
all.

When SIGHUP is raised (this means that sheep exits unexpectedly), the
logger works as before.

Thanks,

Kazutaka



More information about the sheepdog mailing list