[lxc-devel] [PATCH] Fix return value of userns_exec_1

Serge Hallyn serge.hallyn at ubuntu.com
Tue Jan 14 23:31:45 UTC 2014


Quoting Stéphane Graber (stgraber at ubuntu.com):
> Instead of always returning -1 and call SYSERROR when the child returns
> non-zero. Have userns_exec_1 always return the return value from the
> function it's calling and let the caller do the error handling (as is
> already done by its only caller).
> 
> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/lxc/conf.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index 7e0eddd..159684c 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -4054,10 +4054,11 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data)
>  		goto err;
>  	}
>  
> -	if ((ret = wait_for_pid(pid)) < 0) {
> -		ERROR("Child returned an error: %d\n", ret);
> -		goto err;
> -	}
> +	ret = wait_for_pid(pid);
> +
> +	close(p[1]);
> +	return ret;
> +
>  err:
>  	if (p[0] != -1)
>  		close(p[0]);
> -- 
> 1.8.5.2
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list