From: Lennart Poettering Date: Wed, 9 Jul 2025 14:27:28 +0000 (+0200) Subject: core: followups for the recent subgroup killing commits X-Git-Tag: v258-rc1~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03b4a607f65aaa452562a38460bc29f0b1e56a14;p=thirdparty%2Fsystemd.git core: followups for the recent subgroup killing commits This is a follow-up for 0f23564ad4a191a92bc5544edf800bb2cfbb3513 and 6b02854f508be3f27b45353dd1d12de7d93cab5f, as suggested here: https://github.com/systemd/systemd/pull/37855#pullrequestreview-2997596953 --- diff --git a/man/org.freedesktop.systemd1.xml b/man/org.freedesktop.systemd1.xml index a49b81b0c62..ea3a14f7183 100644 --- a/man/org.freedesktop.systemd1.xml +++ b/man/org.freedesktop.systemd1.xml @@ -1339,11 +1339,11 @@ node /org/freedesktop/systemd1 { matching process was found (otherwise it will return successfully, executing no operation). KillUnitSubgroup() is just like KillUnit() but takes an - additional path argument that selects a sub-control-group of the unit's control group. Only processes + additional path argument that selects a sub-control group of the unit's control group. Only processes in that subgroup are killed. The path my be specified with our without leading /, in both cases it is taken relatively to the unit's control group. If the subgroup path is specified as an empty string or as / it has the same effect as KillUnit(). If - it is specified as anything else the who parameter must be set to either + it is specified as anything else the whom parameter must be set to either cgroup or cgroup-fail. QueueSignalUnit() is similar to KillUnit() but may be diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 6b6b8916de4..50805fd531b 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -826,14 +826,14 @@ static int method_start_unit_replace(sd_bus_message *message, void *userdata, sd } static int method_kill_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { - /* We don't bother with GENERIC_UNIT_LOAD nor GENERIC_UNIT_VALIDATE_LOADED here, as it shouldn't - * matter whether a unit is loaded for killing any processes possibly in the unit's cgroup. */ + /* We don't bother with GENERIC_UNIT_LOAD or GENERIC_UNIT_VALIDATE_LOADED here, as it shouldn't + * matter whether a unit is loaded for killing any processes in the unit's cgroup. */ return method_generic_unit_operation(message, userdata, error, bus_unit_method_kill, 0); } static int method_kill_unit_subgroup(sd_bus_message *message, void *userdata, sd_bus_error *error) { - /* We don't bother with GENERIC_UNIT_LOAD nor GENERIC_UNIT_VALIDATE_LOADED here, as it shouldn't - * matter whether a unit is loaded for killing any processes possibly in the unit's cgroup. */ + /* We don't bother with GENERIC_UNIT_LOAD or GENERIC_UNIT_VALIDATE_LOADED here, as it shouldn't + * matter whether a unit is loaded for killing any processes in the unit's cgroup. */ return method_generic_unit_operation(message, userdata, error, bus_unit_method_kill_subgroup, 0); } diff --git a/src/core/unit.c b/src/core/unit.c index 9051fc69236..26d196cfcaa 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -4065,10 +4065,12 @@ int unit_kill( if (subgroup) { if (!IN_SET(whom, KILL_CGROUP, KILL_CGROUP_FAIL)) - return sd_bus_error_set(ret_error, SD_BUS_ERROR_NOT_SUPPORTED, "Killing by subgroup is only supported for 'cgroup' or 'cgroup-kill' modes."); + return sd_bus_error_set(ret_error, SD_BUS_ERROR_NOT_SUPPORTED, + "Killing by subgroup is only supported for 'cgroup' or 'cgroup-kill' modes."); if (!unit_cgroup_delegate(u)) - return sd_bus_error_set(ret_error, SD_BUS_ERROR_NOT_SUPPORTED, "Killing by subgroup is only available for units with control group delegation enabled."); + return sd_bus_error_set(ret_error, SD_BUS_ERROR_NOT_SUPPORTED, + "Killing by subgroup is only available for units with control group delegation enabled."); } main_pid = unit_main_pid(u); diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index cfe206a94ba..47a88676305 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -260,7 +260,7 @@ static int systemctl_help(void) { " --kill-whom=WHOM Whom to send signal to\n" " --kill-value=INT Signal value to enqueue\n" " --kill-subgroup=PATH\n" - " Send signal to sub-control-group only\n" + " Send signal to sub-control group only\n" " --what=RESOURCES Which types of resources to remove\n" " --now Start or stop unit after enabling or disabling it\n" " --dry-run Only print what would be done\n" diff --git a/test/units/TEST-07-PID1.subgroup-kill.sh b/test/units/TEST-07-PID1.subgroup-kill.sh index f62340e7ea4..c8eb6539abb 100755 --- a/test/units/TEST-07-PID1.subgroup-kill.sh +++ b/test/units/TEST-07-PID1.subgroup-kill.sh @@ -36,4 +36,4 @@ systemctl kill user@"$(id -u testuser)".service --kill-subgroup=app.slice/subgro run0 -u testuser systemctl --user is-active subgroup-test.service systemctl kill user@"$(id -u testuser)".service --kill-subgroup=app.slice/subgroup-test.service --kill-whom=cgroup-fail -timeout 60 bash -c 'while run0 -u testuser systemctl --user is-active subgroup-test.service ; do sleep 1 ; done' +timeout 60 bash -c 'while run0 -u testuser systemctl --user is-active subgroup-test.service; do sleep 1; done'