summaryrefslogtreecommitdiffstats
path: root/api.c
diff options
context:
space:
mode:
authorBalbir Singh <balbir@linux.vnet.ibm.com>2008-04-10 11:37:35 +0000
committerBalbir Singh <balbir@linux.vnet.ibm.com>2008-04-10 11:37:35 +0000
commit95a73795a8dc1dcd3888150bbafc52254296ab3c (patch)
tree75aac9c7e7241ec1eb0bace63ce312531614fac6 /api.c
parent807404116413414133a7adf40e964ab82192a68b (diff)
downloadlibcg-95a73795a8dc1dcd3888150bbafc52254296ab3c.tar.gz
libcg-95a73795a8dc1dcd3888150bbafc52254296ab3c.tar.xz
libcg-95a73795a8dc1dcd3888150bbafc52254296ab3c.zip
This patch fixes file handle leaks as noticed by Paul Menage.
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/branches/balbir@8 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'api.c')
-rw-r--r--api.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/api.c b/api.c
index 756a331..df594ea 100644
--- a/api.c
+++ b/api.c
@@ -48,6 +48,7 @@ int cg_init()
return ECGROUPNOTMOUNTED;
}
strcpy(MOUNT_POINT, ent->mnt_dir);
+ fclose(proc_mount);
return 0;
}
@@ -67,6 +68,7 @@ static int cg_test_mounted_fs()
if (ent == NULL)
return 0;
}
+ fclose(proc_mount);
return 1;
}
@@ -114,6 +116,7 @@ int cg_attach_task_pid(struct cgroup *cgroup, pid_t tid)
}
}
fprintf(tasks, "%d", tid);
+ fclose(tasks);
return 0;
@@ -196,11 +199,13 @@ static int cg_set_control_value(char *path, char *val)
if (errno == ENOENT)
return ECGROUPSUBSYSNOTMOUNTED;
}
+ fclose(control_file);
return ECGROUPNOTALLOWED;
}
}
fprintf(control_file, "%s", val);
+ fclose(control_file);
return 0;
}
@@ -242,27 +247,10 @@ err:
}
-/*
- * WARNING: This API is not final. It WILL change format to use
- * struct cgroup. This API will then become internal and be called something
- * else.
- *
- * I am still not happy with how the data structure is looking at the moment,
- * plus there are a couple of additional details to be worked out. Please
- * do not rely on this API.
- *
- * Be prepared to change the implementation later once it shifts to
- * struct cgroup in the real alpha release.
- *
- * The final version is expected to be
+/** create_cgroup creates a new control group.
+ * struct cgroup *cgroup: The control group to be created
*
- * int create_cgroup(struct cgroup *group);
- *
- * where group is the group to be created
- *
- * Also this version is still at one level since we do not have
- * multi-hierarchy support in kernel. The real alpha release should have this
- * issue sorted out as well.
+ * returns 0 on success.
*/
int cg_create_cgroup(struct cgroup *cgroup)
{