[PATCH] activation: set children oom_score_adj to 0
WaLyong Cho
walyong.cho at samsung.com
Tue Jun 7 11:53:19 UTC 2016
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 | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c
index afdcd68..3d34642 100644
--- a/dbus/dbus-spawn.c
+++ b/dbus/dbus-spawn.c
@@ -30,6 +30,7 @@
#include "dbus-test.h"
#include "dbus-protocol.h"
+#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
@@ -1359,6 +1360,8 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
}
else if (grandchild_pid == 0)
{
+ FILE *file;
+
/* Go back to ignoring SIGPIPE, since it's evil
*/
signal (SIGPIPE, SIG_IGN);
@@ -1373,6 +1376,14 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
close_and_invalidate (&fd_out);
close_and_invalidate (&fd_err);
#endif
+
+ file = fopen ("/proc/self/oom_score_adj", "w");
+ if (!file)
+ _dbus_assert_not_reached ("Got to code fopen().");
+
+ fprintf (file, "0");
+ fclose (file);
+
do_exec (child_err_report_pipe[WRITE_END],
argv,
env,
--
2.5.5
More information about the dbus
mailing list