Skip to content

Commit

Permalink
attach: fix fallback logic when attaching to cgroups
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 4, 2021
1 parent 02efd04 commit 9a57778
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lxc/attach.c
Expand Up @@ -1636,16 +1636,22 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
* enough.
*/
ret = cgroup_attach(conf, name, lxcpath, pid);
if (ret == -ENOCGROUP2) {
if (ret) {
call_cleaner(cgroup_exit) struct cgroup_ops *cgroup_ops = NULL;

if (ret != -ENOCGROUP2) {
SYSERROR("Failed to attach cgroup");
goto on_error;
}

cgroup_ops = cgroup_init(conf);
if (!cgroup_ops)
goto on_error;

if (!cgroup_ops->attach(cgroup_ops, conf, name, lxcpath, pid))
goto on_error;
}

TRACE("Moved intermediate process %d into container's cgroups", pid);
}

Expand Down

0 comments on commit 9a57778

Please sign in to comment.