mirror of
https://github.com/systemd/systemd
synced 2024-10-06 16:21:34 +00:00
scope: count successful cgroup additions when delegating via D-Bus
Since commit8d3e4ac7cd
("scope: refuse activation of scopes if no PIDs to add are left") all "systemd-run --scope --user" calls fail because cgroup attachments delegated to the system instance are not counted towards successful additions. Fix this by incrementing the return value in case unit_attach_pid_to_cgroup_via_bus() succeeds, similar to what happens when cg_attach() succeeds directly. Note that this can *not* distinguish the case when unit_attach_pid_to_cgroup_via_bus() has been run successfully, but all processes to attach are gone in the meantime, unlike the checks that commit8d3e4ac7cd
adds for the system instance. This is because even though unit_attach_pid_to_cgroup_via_bus() leads to an internal unit_attach_pids_to_cgroup() call, the return value over D-Bus does not include the number of successfully attached processes and is always NULL on success. Fixes: #21297
This commit is contained in:
parent
84b10e536c
commit
c65417a011
|
@ -2283,8 +2283,11 @@ int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) {
|
|||
z = unit_attach_pid_to_cgroup_via_bus(u, pid, suffix_path);
|
||||
if (z < 0)
|
||||
log_unit_info_errno(u, z, "Couldn't move process "PID_FMT" to requested cgroup '%s' (directly or via the system bus): %m", pid, empty_to_root(p));
|
||||
else
|
||||
else {
|
||||
if (ret >= 0)
|
||||
ret++; /* Count successful additions */
|
||||
continue; /* When the bus thing worked via the bus we are fully done for this PID. */
|
||||
}
|
||||
}
|
||||
|
||||
if (ret >= 0)
|
||||
|
|
Loading…
Reference in a new issue