From 95a73795a8dc1dcd3888150bbafc52254296ab3c Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Thu, 10 Apr 2008 11:37:35 +0000 Subject: This patch fixes file handle leaks as noticed by Paul Menage. Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/branches/balbir@8 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- api.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'api.c') 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) { -- cgit