mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 09:56:51 +03:00
core: make EPERM errors when applying OOM adjustment for forked processes non-fatal
This should be useful for user namespaces.
This commit is contained in:
parent
f7621db0e3
commit
d5243d6286
@ -1406,12 +1406,16 @@ static int exec_child(ExecCommand *command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (context->oom_score_adjust_set) {
|
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);
|
/* When we can't make this change due to EPERM, then
|
||||||
char_array_0(t);
|
* 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;
|
*error = EXIT_OOM_ADJUST;
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user