[lxc-devel] [PATCH] lxc-create: Don't print the help message twice

Serge Hallyn serge.hallyn at ubuntu.com
Thu Jan 16 04:22:40 UTC 2014


Quoting Stéphane Graber (stgraber at ubuntu.com):
> The forking logic was wrong, causing both the child and the parent to
> call the template with -h.
> 
> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>

<chuckle>

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

> ---
>  src/lxc/lxc_create.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lxc/lxc_create.c b/src/lxc/lxc_create.c
> index 6d94709..058dc43 100644
> --- a/src/lxc/lxc_create.c
> +++ b/src/lxc/lxc_create.c
> @@ -107,10 +107,13 @@ static void create_helpfn(const struct lxc_arguments *args) {
>  
>  	if (!args->template)
>  		return;
> -	if ((pid = fork()) < 0)
> -		return;
> -	if (pid)
> +
> +	pid = fork();
> +	if (pid) {
>  		wait_for_pid(pid);
> +		return;
> +	}
> +
>  	len = strlen(LXCTEMPLATEDIR) + strlen(args->template) + strlen("/lxc-") + 1;
>  	path = alloca(len);
>  	ret = snprintf(path, len,  "%s/lxc-%s", LXCTEMPLATEDIR, args->template);
> -- 
> 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