summaryrefslogtreecommitdiff
path: root/src/core/scope.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-10-27 23:17:50 +0200
committerLennart Poettering <lennart@poettering.net>2021-10-27 23:17:50 +0200
commit8d3e4ac7cd37200d1431411a4b98925a24b7d9b3 (patch)
tree140d19763d78c1c9e3a1d3814528720a2d942059 /src/core/scope.c
parentdb4229d12f48663400802171b336c7cadbbe04ef (diff)
downloadsystemd-8d3e4ac7cd37200d1431411a4b98925a24b7d9b3.tar.gz
scope: refuse activation of scopes if no PIDs to add are left
If all processes we are supposed to add are gone by the time we are ready to do so, let's fail. THis is heavily based on Cunlong Li's work, who thankfully tracked this down. Replaces: #20577
Diffstat (limited to 'src/core/scope.c')
-rw-r--r--src/core/scope.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/scope.c b/src/core/scope.c
index 74f16233c5..63d3288caf 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -391,6 +391,12 @@ static int scope_start(Unit *u) {
scope_enter_dead(s, SCOPE_FAILURE_RESOURCES);
return r;
}
+ if (r == 0) {
+ log_unit_warning(u, "No PIDs left to attach to the scope's control group, refusing: %m");
+ scope_enter_dead(s, SCOPE_FAILURE_RESOURCES);
+ return -ECHILD;
+ }
+ log_unit_debug(u, "%i %s added to scope's control group.", r, r == 1 ? "process" : "processes");
s->result = SCOPE_SUCCESS;