X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcgroup.c;h=108c4fcf5e1799d3503bb1f433bf4bd7df9cd412;hb=2cb1a60d14f869023652482a380ca7b659dcf78f;hp=56529eb6b23b5938a38e648e83a76dda4491f7d6;hpb=53f7d807bff9c39e9e565ad2fb20f29b4306af40;p=elogind.git diff --git a/src/cgroup.c b/src/cgroup.c index 56529eb6b..108c4fcf5 100644 --- a/src/cgroup.c +++ b/src/cgroup.c @@ -70,12 +70,7 @@ int cgroup_bonding_realize(CGroupBonding *b) { goto fail; } - if (b->inherit) - r = cgroup_create_cgroup_from_parent(b->cgroup, true); - else - r = cgroup_create_cgroup(b->cgroup, true); - - if (r != 0) { + if ((r = cgroup_create_cgroup(b->cgroup, true)) != 0) { r = translate_error(r, errno); goto fail; } @@ -194,7 +189,10 @@ int cgroup_bonding_kill(CGroupBonding *b, int sig) { r = 0; goto kill_done; } else { - r = translate_error(r, errno); + if (r == ECGOTHER && errno == ENOENT) + r = ESRCH; + else + r = translate_error(r, errno); break; } } @@ -537,6 +535,37 @@ int cgroup_notify_empty(Manager *m, const char *group) { return 0; } +Unit* cgroup_unit_by_pid(Manager *m, pid_t pid) { + CGroupBonding *l, *b; + char *group = NULL; + int r; + + assert(m); + + if (pid <= 1) + return NULL; + + if ((r = cgroup_get_current_controller_path(pid, m->cgroup_controller, &group))) + return NULL; + + l = hashmap_get(m->cgroup_bondings, group); + free(group); + + if (!l) + return NULL; + + LIST_FOREACH(by_path, b, l) { + + if (!b->unit) + continue; + + if (b->only_us) + return b->unit; + } + + return NULL; +} + CGroupBonding *cgroup_bonding_find_list(CGroupBonding *first, const char *controller) { CGroupBonding *b;