diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-01-08 23:12:16 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-01-08 23:13:45 +0100 |
commit | d5243d628624038567c576e9b69c1d775eb05a05 (patch) | |
tree | 22747595fe2fc046360e695e3e73799b7657121f /src/core | |
parent | f7621db0e38c3e96d48766ae648f1b7a0949ea13 (diff) |
core: make EPERM errors when applying OOM adjustment for forked processes non-fatal
This should be useful for user namespaces.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/execute.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/execute.c b/src/core/execute.c index 0af4227b0e..63d295cf41 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1406,12 +1406,16 @@ static int exec_child(ExecCommand *command, } if (context->oom_score_adjust_set) { - char t[16]; + char t[DECIMAL_STR_MAX(context->oom_score_adjust)]; - snprintf(t, sizeof(t), "%i", context->oom_score_adjust); - char_array_0(t); + /* When we can't make this change due to EPERM, then + * let's silently skip over it. User namespaces + * prohibit write access to this file, and we + * shouldn't trip up over that. */ - if (write_string_file("/proc/self/oom_score_adj", t) < 0) { + sprintf(t, "%i", context->oom_score_adjust); + err = write_string_file("/proc/self/oom_score_adj", t); + if (err < 0 && err != -EPERM) { *error = EXIT_OOM_ADJUST; return -errno; } |