diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 6cab4b5ee05..042a742fa9b 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -2607,7 +2607,7 @@ void unit_add_to_cgroup_empty_queue(Unit *u) { log_debug_errno(r, "Failed to enable cgroup empty event source: %m"); } -static int unit_check_oom(Unit *u) { +int unit_check_oom(Unit *u) { _cleanup_free_ char *oom_kill = NULL; bool increased; uint64_t c; diff --git a/src/core/cgroup.h b/src/core/cgroup.h index be8be1b7e76..fe347ea1145 100644 --- a/src/core/cgroup.h +++ b/src/core/cgroup.h @@ -197,6 +197,7 @@ int unit_watch_cgroup(Unit *u); int unit_watch_cgroup_memory(Unit *u); void unit_add_to_cgroup_empty_queue(Unit *u); +int unit_check_oom(Unit *u); int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path); diff --git a/src/core/manager.c b/src/core/manager.c index c11cb23aa9f..a3dc5bb40ea 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2524,8 +2524,13 @@ static int manager_dispatch_sigchld(sd_event_source *source, void *userdata) { /* Finally, execute them all. Note that u1, u2 and the array might contain duplicates, but * that's fine, manager_invoke_sigchld_event() will ensure we only invoke the handlers once for * each iteration. */ - if (u1) + if (u1) { + /* We check for oom condition, in case we got SIGCHLD before the oom notification. + * We only do this for the cgroup the PID belonged to. */ + (void) unit_check_oom(u1); + manager_invoke_sigchld_event(m, u1, &si); + } if (u2) manager_invoke_sigchld_event(m, u2, &si); if (array_copy) diff --git a/src/core/service.c b/src/core/service.c index cfb0a7bc729..f16601a7288 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2047,9 +2047,10 @@ static int service_adverse_to_leftover_processes(Service *s) { * aren't as rigoriously written to protect aganst against multiple use. */ if (unit_warn_leftover_processes(UNIT(s)) && IN_SET(s->kill_context.kill_mode, KILL_MIXED, KILL_CONTROL_GROUP) && - !s->kill_context.send_sigkill) { - return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(EBUSY), "Will not start SendSIGKILL=no service of type KillMode=control-group or mixed while processes exist"); - } + !s->kill_context.send_sigkill) + return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(EBUSY), + "Will not start SendSIGKILL=no service of type KillMode=control-group or mixed while processes exist"); + return 0; }