From: Nikola Forró Date: Thu, 16 Jan 2020 17:43:52 +0000 (+0100) Subject: api.c: Show warning when tasks file can not be opened X-Git-Tag: v0.42.1~1^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b7df54acb1ab60ae6e1d98418b23aec585d1415;p=thirdparty%2Flibcgroup.git api.c: Show warning when tasks file can not be opened Signed-off-by: Nikola Forró Reviewed-by: Tom Hromatka --- diff --git a/src/api.c b/src/api.c index e7a07cfc..96e082fc 100644 --- a/src/api.c +++ b/src/api.c @@ -1382,12 +1382,15 @@ static int __cgroup_attach_task_pid(char *path, pid_t tid) if (!tasks) { switch (errno) { case EPERM: - return ECGROUPNOTOWNER; + ret = ECGROUPNOTOWNER; + break; case ENOENT: - return ECGROUPNOTEXIST; + ret = ECGROUPNOTEXIST; + break; default: - return ECGROUPNOTALLOWED; + ret = ECGROUPNOTALLOWED; } + goto err; } ret = fprintf(tasks, "%d", tid); if (ret < 0) { @@ -1406,7 +1409,8 @@ static int __cgroup_attach_task_pid(char *path, pid_t tid) err: cgroup_warn("Warning: cannot write tid %d to %s:%s\n", tid, path, strerror(errno)); - fclose(tasks); + if (tasks) + fclose(tasks); return ret; }