From 6399215a54a22845b1310610011c9229e248e1be Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 14 Jan 2009 11:35:56 +0000 Subject: Open /proc/self/oom_adj with O_RDONLY or O_WRONLY as necessary, rather than O_RDWR. --- openbsd-compat/port-linux.c | 10 +++++----- openbsd-compat/port-linux.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'openbsd-compat') diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c index bc4924727..b7142ba90 100644 --- a/openbsd-compat/port-linux.c +++ b/openbsd-compat/port-linux.c @@ -197,10 +197,10 @@ ssh_selinux_setup_pty(char *pwname, const char *tty) #ifdef OOM_ADJUST /* Get the out-of-memory adjustment file for the current process */ -int -oom_adj_open(void) +static int +oom_adj_open(int oflag) { - int fd = open("/proc/self/oom_adj", O_RDWR); + int fd = open("/proc/self/oom_adj", oflag); if (fd < 0) logit("error opening /proc/self/oom_adj: %s", strerror(errno)); return fd; @@ -211,7 +211,7 @@ int oom_adj_get(char *buf, size_t maxlen) { ssize_t n; - int fd = oom_adj_open(); + int fd = oom_adj_open(O_RDONLY); if (fd < 0) return -1; n = read(fd, buf, maxlen); @@ -228,7 +228,7 @@ int oom_adj_set(const char *buf) { ssize_t n; - int fd = oom_adj_open(); + int fd = oom_adj_open(O_WRONLY); if (fd < 0) return -1; n = write(fd, buf, strlen(buf)); diff --git a/openbsd-compat/port-linux.h b/openbsd-compat/port-linux.h index 2a3271a93..6e6a8acfd 100644 --- a/openbsd-compat/port-linux.h +++ b/openbsd-compat/port-linux.h @@ -26,7 +26,6 @@ void ssh_selinux_setup_exec_context(char *); #endif #ifdef OOM_ADJUST -int oom_adj_open(void); int oom_adj_get(char *buf, size_t maxlen); int oom_adj_set(const char *buf); #endif -- cgit v1.2.3