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

Liu Yuan namei.unix at gmail.com
Fri Apr 12 10:02:17 CEST 2013


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.

> +
> +               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."?

Thanks,
Yuan



More information about the sheepdog mailing list