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;
}
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;
}
}
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;