[sheepdog] [PATCH] sheep: let sheep return correct exit status when locking a base directory fails

MORITA Kazutaka morita.kazutaka at gmail.com
Wed May 8 18:18:44 CEST 2013


At Tue,  7 May 2013 01:15:41 +0900,
Hitoshi Mitake wrote:
> 
> Currently, lock_and_daemon() always returns 0 as its exit
> status. But this behavior is confusing because users cannot detect
> errors during locking a base directory via the exit status. This patch
> modifies lock_and_daemon() for returning correct exit status.
> 
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
>  sheep/sheep.c |   49 +++++++++++++++++++++++++++++++++++++------------
>  1 files changed, 37 insertions(+), 12 deletions(-)
> 
> diff --git a/sheep/sheep.c b/sheep/sheep.c
> index a7e3820..64f04ca 100644
> --- a/sheep/sheep.c
> +++ b/sheep/sheep.c
> @@ -392,7 +392,12 @@ static void check_host_env(void)
>  
>  static int lock_and_daemon(bool daemonize, const char *base_dir)
>  {
> -	int ret, devnull_fd = 0;
> +	int ret, devnull_fd = 0, status = 0;
> +	int pipefd[2];
> +
> +	ret = pipe(pipefd);
> +	if (ret < 0)
> +		panic("pipe() for passing exit status failed: %m");

Can we use eventfd instead of pipe?

Thanks,

Kazutaka



More information about the sheepdog mailing list