summaryrefslogtreecommitdiff
path: root/psutil
diff options
context:
space:
mode:
Diffstat (limited to 'psutil')
-rw-r--r--psutil/_psutil_posix.c4
-rw-r--r--psutil/arch/freebsd/specific.c9
2 files changed, 9 insertions, 4 deletions
diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c
index f1d2afd6..876b4129 100644
--- a/psutil/_psutil_posix.c
+++ b/psutil/_psutil_posix.c
@@ -15,7 +15,6 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
-#include <sys/resource.h>
#ifdef PSUTIL_SUNOS10
#include "arch/solaris/v10/ifaddrs.h"
@@ -42,6 +41,9 @@
#elif defined(PSUTIL_AIX)
#include <netdb.h>
#endif
+#if defined(PSUTIL_LINUX) || defined(PSUTIL_FREEBSD)
+ #include <sys/resource.h>
+#endif
#include "_psutil_common.h"
diff --git a/psutil/arch/freebsd/specific.c b/psutil/arch/freebsd/specific.c
index cf281bda..fcfce131 100644
--- a/psutil/arch/freebsd/specific.c
+++ b/psutil/arch/freebsd/specific.c
@@ -1079,6 +1079,9 @@ error:
}
+/*
+ * An emulation of Linux prlimit(). Returns a (soft, hard) tuple.
+ */
PyObject *
psutil_proc_getrlimit(PyObject *self, PyObject *args) {
pid_t pid;
@@ -1114,6 +1117,9 @@ psutil_proc_getrlimit(PyObject *self, PyObject *args) {
}
+/*
+ * An emulation of Linux prlimit() (set).
+ */
PyObject *
psutil_proc_setrlimit(PyObject *self, PyObject *args) {
pid_t pid;
@@ -1122,7 +1128,6 @@ psutil_proc_setrlimit(PyObject *self, PyObject *args) {
int name[5];
struct rlimit new;
struct rlimit *newp = NULL;
-
PyObject *py_soft = NULL;
PyObject *py_hard = NULL;
@@ -1151,9 +1156,7 @@ psutil_proc_setrlimit(PyObject *self, PyObject *args) {
if (new.rlim_max == (rlim_t) - 1 && PyErr_Occurred())
return NULL;
#endif
-
newp = &new;
-
ret = sysctl(name, 5, NULL, 0, newp, sizeof(*newp));
if (ret == -1)
return PyErr_SetFromErrno(PyExc_OSError);