naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
2aacef
From df85e937594d551c91a1efd5ba73d56399304f19 Mon Sep 17 00:00:00 2001
2aacef
From: Mark Laws <mdl@60hz.org>
2aacef
Date: Thu, 24 Nov 2022 14:56:29 +0900
2aacef
Subject: [PATCH] systemd: Default to OOMPolicy=continue for login session
2aacef
 scopes
2aacef
2aacef
If the kernel OOM kills a process under a login session scope, we don't want to
2aacef
kill the user's other processes for no good reason.
2aacef
2aacef
(cherry picked from commit 98b6c94b577205d31b019286c2a84cc9af244ea0)
2aacef
2aacef
Resolves: #2175619
2aacef
---
2aacef
 src/login/logind-dbus.c | 6 ++++++
2aacef
 1 file changed, 6 insertions(+)
2aacef
2aacef
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
2aacef
index 86a5decf3f..2ab26b9c6d 100644
2aacef
--- a/src/login/logind-dbus.c
2aacef
+++ b/src/login/logind-dbus.c
2aacef
@@ -3970,6 +3970,12 @@ int manager_start_scope(
2aacef
         if (r < 0)
2aacef
                 return r;
2aacef
 
2aacef
+        /* For login session scopes, if a process is OOM killed by the kernel, *don't* terminate the rest of
2aacef
+           the scope */
2aacef
+        r = sd_bus_message_append(m, "(sv)", "OOMPolicy", "s", "continue");
2aacef
+        if (r < 0)
2aacef
+                return r;
2aacef
+
2aacef
         /* disable TasksMax= for the session scope, rely on the slice setting for it */
2aacef
         r = sd_bus_message_append(m, "(sv)", "TasksMax", "t", UINT64_MAX);
2aacef
         if (r < 0)