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.
This commit is contained in:
Lennart Poettering
2018-01-23 21:22:50 +01:00
parent eb5eb254dd
commit 2ca9d97943
+1 -1
View File
@@ -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));