[lxc-devel] [PATCH] lxc_cgroup_append_task_2of3() helper_2of2

Greg Kurz gkurz at fr.ibm.com
Thu Oct 6 14:07:58 UTC 2011


On Thu, 2011-10-06 at 15:00 +0200, "Axel Schöner" wrote:
> diff --git a/src/lxc/namespace.h b/src/lxc/namespace.h
> index 9c6b7ec..cda6c50 100644
> --- a/src/lxc/namespace.h
> +++ b/src/lxc/namespace.h
> @@ -49,6 +49,7 @@
>  #endif
> 
>  extern pid_t lxc_clone(int (*fn)(void *), void *arg, int flags);
> -extern int lxc_attach(pid_t pid);
> +extern int lxc_attach(pid_t pid, const char* cgname);
> +extern int lxc_cgroup_append_task(const char *name, pid_t pid);
> 
>  #endif
> diff --git a/src/lxc/namespace.c b/src/lxc/namespace.c
> index aca29d4..86d1e53 100644
> --- a/src/lxc/namespace.c
> +++ b/src/lxc/namespace.c
> @@ -82,7 +82,7 @@ pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
>         return ret;
>  }
> 
> -int lxc_attach(pid_t pid)
> +int lxc_attach(pid_t pid, const char* cgname)
>  {
>         char path[MAXPATHLEN];
>         char *ns[] = { "pid", "mnt", "net", "ipc", "uts" };
> @@ -104,6 +104,13 @@ int lxc_attach(pid_t pid)
>                         return -1;
>                 }
>         }
> +       pid_t cpid = getpid();
> +
> +       /* Let's add the pid to the 'tasks' file */
> +       if (lxc_cgroup_append_task(cgname, cpid)) {
> +               SYSERROR("failed to attach pid '%d' to '%s'", cpid, cgname);
> +               return -1;
> +       }
> 
>         for (i = 0; i < size; i++) {
>                 if (setns(fd[i], 0)) {

Acked-by: Greg Kurz <gkurz at fr.ibm.com>

-- 
Gregory Kurz                                     gkurz at fr.ibm.com
Software Engineer @ IBM/Meiosys                  http://www.ibm.com
Tel +33 (0)534 638 479                           Fax +33 (0)561 400 420

"Anarchy is about taking complete responsibility for yourself."
        Alan Moore.





More information about the lxc-devel mailing list