[lxc-devel] [PATCH 2/5] utils.c: Add lxc_wait_for_pid_status routine that returns exit code

Serge Hallyn serge.hallyn at ubuntu.com
Mon May 20 18:31:06 UTC 2013


Quoting Christian Seiler (christian at iwakd.de):
> Signed-off-by: Christian Seiler <christian at iwakd.de>

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

> ---
>  src/lxc/utils.c |   16 ++++++++++++++++
>  src/lxc/utils.h |    3 +++
>  2 files changed, 19 insertions(+), 0 deletions(-)
> 
> diff --git a/src/lxc/utils.c b/src/lxc/utils.c
> index cf42c38..66bd19d 100644
> --- a/src/lxc/utils.c
> +++ b/src/lxc/utils.c
> @@ -265,3 +265,19 @@ again:
>  		return -1;
>  	return 0;
>  }
> +
> +int lxc_wait_for_pid_status(pid_t pid)
> +{
> +	int status, ret;
> +
> +again:
> +	ret = waitpid(pid, &status, 0);
> +	if (ret == -1) {
> +		if (errno == EINTR)
> +			goto again;
> +		return -1;
> +	}
> +	if (ret != pid)
> +		goto again;
> +	return status;
> +}
> diff --git a/src/lxc/utils.h b/src/lxc/utils.h
> index 09af34a..be1a8a8 100644
> --- a/src/lxc/utils.h
> +++ b/src/lxc/utils.h
> @@ -23,6 +23,8 @@
>  #ifndef _utils_h
>  #define _utils_h
>  
> +#include <sys/types.h>
> +
>  extern int lxc_setup_fs(void);
>  extern int get_u16(unsigned short *val, const char *arg, int base);
>  extern int mkdir_p(const char *dir, mode_t mode);
> @@ -64,5 +66,6 @@ extern int __build_bug_on_failed;
>   * wait on a child we forked
>   */
>  extern int wait_for_pid(pid_t pid);
> +extern int lxc_wait_for_pid_status(pid_t pid);
>  
>  #endif
> -- 
> 1.7.8.6
> 
> 
> ------------------------------------------------------------------------------
> AlienVault Unified Security Management (USM) platform delivers complete
> security visibility with the essential security capabilities. Easily and
> efficiently configure, manage, and operate all of your security controls
> from a single console and one unified framework. Download a free trial.
> http://p.sf.net/sfu/alienvault_d2d
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list