From: Christian Brauner Date: Thu, 4 Feb 2021 14:01:09 +0000 (+0100) Subject: attach: fix fallback logic when attaching to cgroups X-Git-Tag: lxc-5.0.0~301^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a57778bb5b2a85f542dd6f9c1c0f37ba4f8b7cc;p=thirdparty%2Flxc.git attach: fix fallback logic when attaching to cgroups Signed-off-by: Christian Brauner --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index d30c0d7f5..03b29338d 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -1636,9 +1636,14 @@ 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; @@ -1646,6 +1651,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, if (!cgroup_ops->attach(cgroup_ops, conf, name, lxcpath, pid)) goto on_error; } + TRACE("Moved intermediate process %d into container's cgroups", pid); }