cgfsng: cgfsng_enter()

parent d1ef2d91
...@@ -1822,18 +1822,22 @@ out_free: ...@@ -1822,18 +1822,22 @@ out_free:
static bool cgfsng_enter(void *hdata, pid_t pid) static bool cgfsng_enter(void *hdata, pid_t pid)
{ {
char pidstr[25];
int i, len; int i, len;
char pidstr[25];
len = snprintf(pidstr, 25, "%d", pid); len = snprintf(pidstr, 25, "%d", pid);
if (len < 0 || len > 25) if (len < 0 || len >= 25)
return false; return false;
for (i = 0; hierarchies[i]; i++) { for (i = 0; hierarchies[i]; i++) {
char *fullpath = must_make_path(hierarchies[i]->fullcgpath, int ret;
"cgroup.procs", NULL); char *fullpath;
if (lxc_write_to_file(fullpath, pidstr, len, false) != 0) {
SYSERROR("Failed to enter %s", fullpath); fullpath = must_make_path(hierarchies[i]->fullcgpath,
"cgroup.procs", NULL);
ret = lxc_write_to_file(fullpath, pidstr, len, false);
if (ret != 0) {
SYSERROR("Failed to enter cgroup \"%s\"", fullpath);
free(fullpath); free(fullpath);
return false; return false;
} }
......
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