const char *error_str = NULL;
#ifdef O_CLOEXEC
- fd = open ("/proc/self/oom_score_adj", O_RDWR | O_CLOEXEC);
+ fd = open ("/proc/self/oom_score_adj", O_RDONLY | O_CLOEXEC);
#endif
if (fd < 0)
{
- fd = open ("/proc/self/oom_score_adj", O_RDWR);
+ fd = open ("/proc/self/oom_score_adj", O_RDONLY);
if (fd >= 0)
_dbus_fd_set_close_on_exec (fd);
}
goto out;
}
+ close (fd);
+#ifdef O_CLOEXEC
+ fd = open ("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC);
+
+ if (fd < 0)
+#endif
+ {
+ fd = open ("/proc/self/oom_score_adj", O_WRONLY);
+ if (fd >= 0)
+ _dbus_fd_set_close_on_exec (fd);
+ }
+
+ if (fd < 0)
+ {
+ ret = FALSE;
+ error_str = "open(/proc/self/oom_score_adj) for writing";
+ saved_errno = errno;
+ goto out;
+ }
+
if (pwrite (fd, "0", sizeof (char), 0) < 0)
{
ret = FALSE;
else
{
ret = FALSE;
- error_str = "open(/proc/self/oom_score_adj)";
+ error_str = "open(/proc/self/oom_score_adj) for reading";
saved_errno = errno;
goto out;
}