process-util: add new helper call for adjusting the OOM score

And let's make use of it in execute.c
This commit is contained in:
Lennart Poettering
2018-05-17 20:47:21 +02:00
parent e9eb2c02f0
commit 9f8168eb23
3 changed files with 14 additions and 9 deletions
+9
View File
@@ -1445,6 +1445,15 @@ int fork_agent(const char *name, const int except[], size_t n_except, pid_t *ret
_exit(EXIT_FAILURE);
}
int set_oom_score_adjust(int value) {
char t[DECIMAL_STR_MAX(int)];
sprintf(t, "%i", value);
return write_string_file("/proc/self/oom_score_adj", t,
WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER);
}
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",