diff options
Diffstat (limited to 'src/core/cgroup.c')
-rw-r--r-- | src/core/cgroup.c | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c index ef9b02f46..7a5f673a7 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c | |||
@@ -108,26 +108,43 @@ void cgroup_bonding_trim_list(CGroupBonding *first, bool delete_root) { | |||
108 | cgroup_bonding_trim(b, delete_root); | 108 | cgroup_bonding_trim(b, delete_root); |
109 | } | 109 | } |
110 | 110 | ||
111 | int cgroup_bonding_install(CGroupBonding *b, pid_t pid) { | 111 | |
112 | int cgroup_bonding_install(CGroupBonding *b, pid_t pid, const char *cgroup_suffix) { | ||
113 | char *p = NULL; | ||
114 | const char *path; | ||
112 | int r; | 115 | int r; |
113 | 116 | ||
114 | assert(b); | 117 | assert(b); |
115 | assert(pid >= 0); | 118 | assert(pid >= 0); |
116 | 119 | ||
117 | if ((r = cg_create_and_attach(b->controller, b->path, pid)) < 0) | 120 | if (cgroup_suffix) { |
121 | p = join(b->path, "/", cgroup_suffix, NULL); | ||
122 | if (!p) | ||
123 | return -ENOMEM; | ||
124 | |||
125 | path = p; | ||
126 | } else | ||
127 | path = b->path; | ||
128 | |||
129 | r = cg_create_and_attach(b->controller, path, pid); | ||
130 | free(p); | ||
131 | |||
132 | if (r < 0) | ||
118 | return r; | 133 | return r; |
119 | 134 | ||
120 | b->realized = true; | 135 | b->realized = true; |
121 | return 0; | 136 | return 0; |
122 | } | 137 | } |
123 | 138 | ||
124 | int cgroup_bonding_install_list(CGroupBonding *first, pid_t pid) { | 139 | int cgroup_bonding_install_list(CGroupBonding *first, pid_t pid, const char *cgroup_suffix) { |
125 | CGroupBonding *b; | 140 | CGroupBonding *b; |
126 | int r; | 141 | int r; |
127 | 142 | ||
128 | LIST_FOREACH(by_unit, b, first) | 143 | LIST_FOREACH(by_unit, b, first) { |
129 | if ((r = cgroup_bonding_install(b, pid)) < 0 && b->essential) | 144 | r = cgroup_bonding_install(b, pid, cgroup_suffix); |
145 | if (r < 0 && b->essential) | ||
130 | return r; | 146 | return r; |
147 | } | ||
131 | 148 | ||
132 | return 0; | 149 | return 0; |
133 | } | 150 | } |
@@ -176,7 +193,11 @@ int cgroup_bonding_set_task_access_list(CGroupBonding *first, mode_t mode, uid_t | |||
176 | return 0; | 193 | return 0; |
177 | } | 194 | } |
178 | 195 | ||
179 | int cgroup_bonding_kill(CGroupBonding *b, int sig, bool sigcont, Set *s) { | 196 | int cgroup_bonding_kill(CGroupBonding *b, int sig, bool sigcont, Set *s, const char *cgroup_suffix) { |
197 | char *p = NULL; | ||
198 | const char *path; | ||
199 | int r; | ||
200 | |||
180 | assert(b); | 201 | assert(b); |
181 | assert(sig >= 0); | 202 | assert(sig >= 0); |
182 | 203 | ||
@@ -184,10 +205,22 @@ int cgroup_bonding_kill(CGroupBonding *b, int sig, bool sigcont, Set *s) { | |||
184 | if (!b->ours) | 205 | if (!b->ours) |
185 | return 0; | 206 | return 0; |
186 | 207 | ||
187 | return cg_kill_recursive(b->controller, b->path, sig, sigcont, true, false, s); | 208 | if (cgroup_suffix) { |
209 | p = join(b->path, "/", cgroup_suffix, NULL); | ||
210 | if (!p) | ||
211 | return -ENOMEM; | ||
212 | |||
213 | path = p; | ||
214 | } else | ||
215 | path = b->path; | ||
216 | |||
217 | r = cg_kill_recursive(b->controller, path, sig, sigcont, true, false, s); | ||
218 | free(p); | ||
219 | |||
220 | return r; | ||
188 | } | 221 | } |
189 | 222 | ||
190 | int cgroup_bonding_kill_list(CGroupBonding *first, int sig, bool sigcont, Set *s) { | 223 | int cgroup_bonding_kill_list(CGroupBonding *first, int sig, bool sigcont, Set *s, const char *cgroup_suffix) { |
191 | CGroupBonding *b; | 224 | CGroupBonding *b; |
192 | Set *allocated_set = NULL; | 225 | Set *allocated_set = NULL; |
193 | int ret = -EAGAIN, r; | 226 | int ret = -EAGAIN, r; |
@@ -200,7 +233,8 @@ int cgroup_bonding_kill_list(CGroupBonding *first, int sig, bool sigcont, Set *s | |||
200 | return -ENOMEM; | 233 | return -ENOMEM; |
201 | 234 | ||
202 | LIST_FOREACH(by_unit, b, first) { | 235 | LIST_FOREACH(by_unit, b, first) { |
203 | if ((r = cgroup_bonding_kill(b, sig, sigcont, s)) < 0) { | 236 | r = cgroup_bonding_kill(b, sig, sigcont, s, cgroup_suffix); |
237 | if (r < 0) { | ||
204 | if (r == -EAGAIN || r == -ESRCH) | 238 | if (r == -EAGAIN || r == -ESRCH) |
205 | continue; | 239 | continue; |
206 | 240 | ||