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

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri Apr 12 10:30:55 CEST 2013


At Fri, 12 Apr 2013 16:02:17 +0800,
Liu Yuan wrote:
> 
> On 04/12/2013 03:53 PM, MORITA Kazutaka wrote:
> > 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);
> 
> We'd better in-line the comment why we call raise() in at least one call
> site. Looks cleaner to write a helper for unexpected  signal handling.

Okay.

> 
> > +
> > +               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.
> > 
> 
> Then the logger process is indeed terminated in the crash_handler(), so
> this unexpected signal causes the termination of logger, no?  This is
> what I am confused at. Why not just "unexpected signal xxx is raised."?

I didn't consider that the unexpected signal triggers the
crash_handler.  Then the reason we reach the line are:

 - The default handler (for SIGSEGV, SIGABRT, SIGBUS, SIGILL, or
   SIGFPE) doesn't terminate the process unexpectedly.

 - The unexpected signal has come and its default handler doesn't
   terminate the process.

Is it okay?  Then I think the current message shows what has happened
clearly.  In either case, we should stop the process immediately
because what we cannot expect has happened.

Anyway, we shouldn't reach the line.  Is it better to print "something
goes wrong" simply if the current message is confusing?

Thanks,

Kazutaka



More information about the sheepdog mailing list