From c2248a6a418b9e4a65f9b4f2c6ca8dc76a876ac5 Mon Sep 17 00:00:00 2001 From: wonghiu45 Date: Tue, 20 Sep 2022 16:28:56 +0800 Subject: [PATCH] fix bug for init sys adj Signed-off-by: wonghiu45 --- services/init/standard/init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/services/init/standard/init.c b/services/init/standard/init.c index 5f21f92b..9e3cc34f 100755 --- a/services/init/standard/init.c +++ b/services/init/standard/init.c @@ -297,6 +297,22 @@ static void InitPostHook(const HOOK_INFO *hookInfo, void *executionContext, int hookInfo->stage, hookInfo->prio, hookInfo->hook, diff, executionRetVal); } +static void InitSysAdj(void) +{ + const char* path = "/proc/1/oom_score_adj"; + const char* content = "-1000"; + int fd = open(path, O_RDWR); + if (fd == -1) { + return; + } + if (write(fd, content, strlen(content)) < 0) { + close(fd); + return; + } + close(fd); + return; +} + static void TriggerServices(int startMode) { int index = 0; @@ -340,6 +356,8 @@ static void TriggerServices(int startMode) void SystemConfig(void) { INIT_TIMING_STAT timingStat; + + InitSysAdj(); HOOK_EXEC_OPTIONS options; options.flags = 0; -- GitLab