]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: correct handling of "systemctl kill --kill-who=main-fail"
authorLennart Poettering <lennart@poettering.net>
Fri, 16 Oct 2020 15:16:23 +0000 (17:16 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 16 Oct 2020 15:19:20 +0000 (17:19 +0200)
--kill-who=main-fail never worked correctly, due to a copy and paste
mistake in ac5e3a505e49c80b56c971a8fc13bacac961640d, where the same item
was listed twice. The mistake was
later noticed, but fixed incorrectly, in
201f0c916d8f65ad2595a651b1371fcd39a4cf55.

Let's list all *-fail types correctly, finally.

And while we are at it, add a nice comment and generate a prettier D-Bus
error about this.

src/core/unit.c

index 052c11c00f4915b61885a2807895ce6ad5b9fcdf..f3d4731a46a7078e8fbe82d74f800a3055474d1c 100644 (file)
@@ -4381,8 +4381,9 @@ int unit_kill_common(
                         killed = true;
         }
 
-        if (r == 0 && !killed && IN_SET(who, KILL_ALL_FAIL, KILL_CONTROL_FAIL))
-                return -ESRCH;
+        /* If the "fail" versions of the operation are requested, then complain if the set of processes we killed is empty */
+        if (r == 0 && !killed && IN_SET(who, KILL_ALL_FAIL, KILL_CONTROL_FAIL, KILL_MAIN_FAIL))
+                return sd_bus_error_set_const(error, BUS_ERROR_NO_SUCH_PROCESS, "No matching processes to kill");
 
         return r;
 }