Unverified Commit 16a3be60 by Christian Brauner Committed by Stéphane Graber

cgroups: move check for valid monitor process up

Cc: cenxianlong <cenxianlong@huawei.com> Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent e5da28dd
...@@ -1082,6 +1082,12 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops, ...@@ -1082,6 +1082,12 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
if (!h->monitor_full_path) if (!h->monitor_full_path)
continue; continue;
/* Monitor might have died before we entered the cgroup. */
if (handler->monitor_pid <= 0) {
WARN("No valid monitor process found while destroying cgroups");
goto try_recursive_destroy;
}
if (conf && conf->cgroup_meta.dir) if (conf && conf->cgroup_meta.dir)
pivot_path = must_make_path(h->mountpoint, pivot_path = must_make_path(h->mountpoint,
h->container_base_path, h->container_base_path,
...@@ -1098,12 +1104,10 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops, ...@@ -1098,12 +1104,10 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
goto try_recursive_destroy; goto try_recursive_destroy;
} }
if (handler->monitor_pid != 0) { ret = lxc_write_openat(pivot_path, "cgroup.procs", pidstr, len);
ret = lxc_write_openat(pivot_path, "cgroup.procs", pidstr, len); if (ret != 0) {
if (ret != 0) { SYSWARN("Failed to move monitor %s to \"%s\"", pidstr, pivot_path);
SYSWARN("Failed to move monitor %s to \"%s\"", pidstr, pivot_path); continue;
continue;
}
} }
try_recursive_destroy: try_recursive_destroy:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment