From: Simon McVittie Date: Mon, 21 Feb 2022 16:07:26 +0000 (+0000) Subject: sysdeps-unix: Diagnose failure to open /proc/self/oom_score_adj X-Git-Tag: dbus-1.12.22~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b38a39884c44470a70a703bba2ff4353c616bb97;p=thirdparty%2Fdbus.git sysdeps-unix: Diagnose failure to open /proc/self/oom_score_adj Previously, we silently ignored this, but now that we're more careful about the contexts in which we try to reset the OOM score and whether we log failures as a warning, we can let the dbus-daemon-launch-helper show a message if it can't write there. Signed-off-by: Simon McVittie (cherry picked from commit 226f24144a4db4898a1f5958293d200b975baee0) --- diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index ffbc7aea1..bed6fd3ee 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -1658,12 +1658,19 @@ _dbus_reset_oom_score_adj (const char **error_str_p) /* Success */ ret = TRUE; } - else + else if (errno == ENOENT) { - /* TODO: Historically we ignored this error, although ideally we - * would diagnose it */ + /* If /proc/self/oom_score_adj doesn't exist, assume the kernel + * doesn't support this feature and ignore it. */ ret = TRUE; } + else + { + ret = FALSE; + error_str = "open(/proc/self/oom_score_adj)"; + saved_errno = errno; + goto out; + } out: if (fd >= 0)