[PATCH] activation: set children oom_score_adj to 0

WaLyong Cho <[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <[email protected]>
If dbus is running as systemd service, dbus daemon is running with
oom_score_adj -900 by OOMScoreAdjust=-900. And children will also have
same value with dbus daemon.
To avoid this, set the child itself values after fork () to 0.
---
 dbus/dbus-spawn.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c
index afdcd68..155622b 100644
--- a/dbus/dbus-spawn.c
+++ b/dbus/dbus-spawn.c
@@ -1359,6 +1359,15 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter          **sitter_p,
 	}
       else if (grandchild_pid == 0)
       {
+#ifdef __linux__
+          int fd = open ("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC);
+
+          if (fd >= 0)
+            {
+              write (fd, "0", sizeof (char));
+              _dbus_close (fd, NULL);
+            }
+#endif
           /* Go back to ignoring SIGPIPE, since it's evil
            */
           signal (SIGPIPE, SIG_IGN);
-- 
2.5.5

_______________________________________________
dbus mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dbus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.