From f7829525be46ddeddcbac39d7f31b12fae52cb5e Mon Sep 17 00:00:00 2001 From: Nishal Kulkarni Date: Mon, 7 Mar 2022 15:41:05 +0530 Subject: [PATCH] core/cgroup: Add OOM check Check if process(es) of a cgroup were killed by Kernel OOM killer or systemd-oomd before we send the cgroup empty notification. This allows us to show the right exit state(ServiceResult) --- src/core/cgroup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/cgroup.c b/src/core/cgroup.c index dda87db7e1..f3b124eb67 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -2958,6 +2958,10 @@ static int on_cgroup_empty_event(sd_event_source *s, void *userdata) { log_debug_errno(r, "Failed to reenable cgroup empty event source, ignoring: %m"); } + /* Update state based on OOM kills before we notify about cgroup empty event */ + (void) unit_check_oom(u); + (void) unit_check_oomd_kill(u); + unit_add_to_gc_queue(u); if (UNIT_VTABLE(u)->notify_cgroup_empty) -- 2.25.1