From e0e7bc8223c3f28fcb48db9f0f003d9f03ca46d7 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Mon, 16 Jan 2023 23:46:01 +0000 Subject: core: add GetUnitByPIDFD method and use it in systemctl A pid can be recycled, but a pidfd is pinned. Add a new method that is safer as it takes a pidfd as input. Return not only the D-Bus object path, but also the unit id and the last recorded invocation id, as they are both useful (especially the id, as converting from a path object to a unit id from a script requires another round-trip via D-Bus). Note that the manager still tracks processes by pid, so theorethically this is not fully error-proof, but on the other hand the method response is synchronous and the manager is single-threaded, so once a call is being processed the unit database will not change anyway. Once the manager switches to use pidfds everywhere, this can be further hardened. --- test/units/testsuite-26.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/units/testsuite-26.sh b/test/units/testsuite-26.sh index 09470a6f06..ee84447d90 100755 --- a/test/units/testsuite-26.sh +++ b/test/units/testsuite-26.sh @@ -245,6 +245,7 @@ systemctl status "systemd-*.timer" systemctl status "systemd-journald*.socket" systemctl status "sys-devices-*-ttyS0.device" systemctl status -- -.mount +systemctl status 1 # --marked systemctl restart "$UNIT_NAME" -- cgit v1.2.1