summaryrefslogtreecommitdiff
path: root/src/cgroup.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-06-16 05:10:31 +0200
committerLennart Poettering <lennart@poettering.net>2010-06-16 05:10:31 +0200
commit8c47c7325fa1ab72febf807f8831ff24c75fbf45 (patch)
tree3a116267ab7c0edbfdb32bbd2b6ea222436fcce3 /src/cgroup.c
parent17586c16bac1d5ecf7d60ef57d18e82e36c288c1 (diff)
notify: add minimal readiness/status protocol for spawned daemons
Diffstat (limited to 'src/cgroup.c')
-rw-r--r--src/cgroup.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/cgroup.c b/src/cgroup.c
index 330014dc9f..108c4fcf5e 100644
--- a/src/cgroup.c
+++ b/src/cgroup.c
@@ -535,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;