Skip to content

Commit

Permalink
Merge pull request #2684 from brauner/2018-10-10/cgfsng_improve_logging
Browse files Browse the repository at this point in the history
cgfsng: improve deletion and logging
  • Loading branch information
stgraber committed Oct 9, 2018
2 parents e2103b1 + d5fc4dd commit d523cf5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/lxc/cgroups/cgfsng.c
Expand Up @@ -1152,6 +1152,7 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,

for (int i = 0; ops->hierarchies[i]; i++) {
int ret;
char *chop;
struct hierarchy *h = ops->hierarchies[i];

if (!h->monitor_full_path)
Expand All @@ -1169,16 +1170,27 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
PIVOT_CGROUP,
"cgroup.procs", NULL);

chop = strrchr(pivot_path, '/');
if (chop)
*chop = '\0';

ret = mkdir_p(pivot_path, 0755);
if (ret < 0 && errno != EEXIST)
if (ret < 0 && errno != EEXIST) {
SYSWARN("Failed to create cgroup \"%s\"\n", pivot_path);
goto next;
}

if (chop)
*chop = '/';

/* Move ourselves into the pivot cgroup to delete our own
* cgroup.
*/
ret = lxc_write_to_file(pivot_path, pidstr, len, false, 0666);
if (ret != 0)
if (ret != 0) {
SYSWARN("Failed to move monitor %s to \"%s\"\n", pidstr, pivot_path);
goto next;
}

ret = recursive_destroy(h->monitor_full_path);
if (ret < 0)
Expand Down

0 comments on commit d523cf5

Please sign in to comment.