Commit 2c495ae3 by Serge Hallyn

cgroup_enter: catch write errors

parent d155b47d
......@@ -769,16 +769,23 @@ int lxc_cgroup_enter(const char *cgpath, pid_t pid)
ret = snprintf(path, MAXPATHLEN, "%s/%s/tasks",
mntent_r.mnt_dir, cgpath);
if (ret < 0 || ret >= MAXPATHLEN) {
ERROR("entering cgroup");
ERROR("Error entering cgroup");
goto out;
}
fout = fopen(path, "w");
if (!fout) {
ERROR("entering cgroup");
SYSERROR("Error entering cgroup");
goto out;
}
if (fprintf(fout, "%d\n", (int)pid) < 0) {
ERROR("Error writing pid to %s", path);
fclose(fout);
goto out;
}
if (fclose(fout) < 0) {
SYSERROR("Error writing pid to %s", path);
goto out;
}
fprintf(fout, "%d\n", (int)pid);
fclose(fout);
}
retv = 0;
......
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