From: Lennart Poettering Date: Thu, 11 Jan 2018 22:38:46 +0000 (+0100) Subject: core: fix manager_get_unit_by_pid() special casing of manager PID X-Git-Tag: v237~37^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ca9d97943ad3a7308597645075cfa1c2fb4543c;p=platform%2Fupstream%2Fsystemd.git core: fix manager_get_unit_by_pid() special casing of manager PID Previously, we'd hard map PID 1 to the manager scope unit. That's wrong however when we are run in --user mode, as the PID 1 is outside of the subtree we manage and the manager PID might be very differently. Correct that by checking for getpid() rather than hardcoding 1. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index c2c4ef1..b3cd120 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -2183,7 +2183,7 @@ Unit *manager_get_unit_by_pid(Manager *m, pid_t pid) { if (pid <= 0) return NULL; - if (pid == 1) + if (pid == getpid_cached()) return hashmap_get(m->units, SPECIAL_INIT_SCOPE); u = hashmap_get(m->watch_pids1, PID_TO_PTR(pid));