From 743f2589c6fb64e50b3b63bc8b235caa00863daf Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Fri, 17 Jun 2016 15:24:33 +0900 Subject: [PATCH] activation: set children oom_score_adj to 0 Change-Id: Ida85bcb12ea8ce0a1af948fb0f1600ed21f3323e Signed-off-by: Hyotaek Shim --- dbus/dbus-spawn.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index ddd254d..d58d798 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -1353,7 +1353,17 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, _dbus_assert_not_reached ("Got to code after write_err_and_exit()"); } 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.7.4