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