]>
Commit | Line | Data |
---|---|---|
9665627f AM |
1 | From 437b68f34c459d136c806e61dafb5825d2f97170 Mon Sep 17 00:00:00 2001 |
2 | From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com> | |
3 | Date: Tue, 17 Apr 2018 13:32:28 +0200 | |
4 | Subject: [PATCH 4/6] api.c: Show warning when tasks file can not be opened | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | Signed-off-by: Nikola Forró <nforro@redhat.com> | |
10 | --- | |
11 | src/api.c | 12 ++++++++---- | |
12 | 1 file changed, 8 insertions(+), 4 deletions(-) | |
13 | ||
14 | diff --git a/src/api.c b/src/api.c | |
15 | index 4d98081..51081b4 100644 | |
16 | --- a/src/api.c | |
17 | +++ b/src/api.c | |
18 | @@ -1190,12 +1190,15 @@ static int __cgroup_attach_task_pid(char *path, pid_t tid) | |
19 | if (!tasks) { | |
20 | switch (errno) { | |
21 | case EPERM: | |
22 | - return ECGROUPNOTOWNER; | |
23 | + ret = ECGROUPNOTOWNER; | |
24 | + break; | |
25 | case ENOENT: | |
26 | - return ECGROUPNOTEXIST; | |
27 | + ret = ECGROUPNOTEXIST; | |
28 | + break; | |
29 | default: | |
30 | - return ECGROUPNOTALLOWED; | |
31 | + ret = ECGROUPNOTALLOWED; | |
32 | } | |
33 | + goto err; | |
34 | } | |
35 | ret = fprintf(tasks, "%d", tid); | |
36 | if (ret < 0) { | |
37 | @@ -1214,7 +1217,8 @@ static int __cgroup_attach_task_pid(char *path, pid_t tid) | |
38 | err: | |
39 | cgroup_warn("Warning: cannot write tid %d to %s:%s\n", | |
40 | tid, path, strerror(errno)); | |
41 | - fclose(tasks); | |
42 | + if (tasks) | |
43 | + fclose(tasks); | |
44 | return ret; | |
45 | } | |
46 | ||
47 | -- | |
48 | 2.17.0 | |
49 |