[Sheepdog] [PATCH v3] logger: correct crash_handler output

Christoph Hellwig hch at infradead.org
Sun Apr 29 12:38:31 CEST 2012


On Sun, Apr 29, 2012 at 08:40:41AM +0800, Liu Yuan wrote:
> From: Liu Yuan <tailai.ly at taobao.com>
> 
> Fix Commit:cc5e7ee93a67acc53's regression
> 
> - fix logger pid output.
> 
> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
> ---
>  lib/logger.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/logger.c b/lib/logger.c
> index 05e62a0..41aa95e 100644
> --- a/lib/logger.c
> +++ b/lib/logger.c
> @@ -388,7 +388,7 @@ static notrace void crash_handler(int signo)
>                 vprintf(SDOG_ERR, "sheep pid %d exited unexpectedly.\n", pid);
>         } else {
>                 vprintf(SDOG_ERR, "logger pid %d got unexpected signal %d.\n",
> -                       pid, signo);
> +                       getpid(), signo);
>         }
> 
>         log_flush();
> @@ -460,6 +460,7 @@ notrace int log_init(char *program_name, int size,
> int to_stdout, int level,
>                 }
> 
>                 /* flush when either the logger or its parent dies */
> +               pid = getppid();

Eww, this is too ugly for words.  Please make "pid" a private variable
inside the block it's used, and add a global sheep_pid variable to hold
the pid for the sheep process.




More information about the sheepdog mailing list