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
ret = r; /* Remember first error */
continue;
- }
+ } else if (ret >= 0)
+ ret++; /* Count successful additions */
r = cg_all_unified();
if (r < 0)
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;