[lxc-devel] [Lxc-devel] [PATCH 1/5] Again: Add pids of lxc-attach to the cgroup of container

"Axel Schöner" axel.schoener at gmx.de
Sun Oct 2 21:31:10 UTC 2011


Sorry my first patchset was not again a complete clean sourcedir ;-(.
I've done a new one, please discard the first one.

Axel Schöner

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)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch_attach_cgroup_1of5_namespace.c
Type: text/x-csrc
Size: 844 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20111002/9d73f01c/attachment.c>


More information about the lxc-devel mailing list