]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/attach.c
cgroups: refactor cgroup handling
[mirror_lxc.git] / src / lxc / attach.c
index e1699b137d48f55ff48618bb3808b7b88745d43a..b62dcecfac481cd7ae59add162197c0355957e53 100644 (file)
@@ -1272,10 +1272,17 @@ int lxc_attach(const char *name, const char *lxcpath,
 
                /* Attach to cgroup, if requested. */
                if (options->attach_flags & LXC_ATTACH_MOVE_TO_CGROUP) {
-                       if (!cgroup_attach(name, lxcpath, pid))
+                       struct cgroup_ops *cgroup_ops;
+
+                       cgroup_ops = cgroup_init(NULL);
+                       if (!cgroup_ops)
+                               goto on_error;
+
+                       if (!cgroup_ops->attach(cgroup_ops, name, lxcpath, pid))
                                goto on_error;
-                       TRACE("Moved intermediate process %d into container's "
-                             "cgroups", pid);
+
+                       cgroup_exit(cgroup_ops);
+                       TRACE("Moved intermediate process %d into container's cgroups", pid);
                }
 
                /* Setup /proc limits */