From 8c47c7325fa1ab72febf807f8831ff24c75fbf45 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 16 Jun 2010 05:10:31 +0200 Subject: notify: add minimal readiness/status protocol for spawned daemons --- src/cgroup.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/cgroup.c') 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; -- cgit v1.2.3-54-g00ecf