summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-10-04 22:02:52 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2016-10-04 22:02:52 +0200
commit9599456623efc09c9d9c2b6f2788eef269fad7f6 (patch)
tree7283d373b7119b9f55235a8eda208ac9a1bc4aa7
parent1175d87a9b5878334cbaa7675e3431fa0f61c47b (diff)
downloadpsutil-9599456623efc09c9d9c2b6f2788eef269fad7f6.tar.gz
remove unneeded C includes
-rw-r--r--psutil/_psutil_bsd.c2
-rw-r--r--psutil/_psutil_posix.h10
-rw-r--r--psutil/arch/bsd/freebsd.c60
-rw-r--r--psutil/arch/bsd/freebsd.h1
-rw-r--r--psutil/arch/bsd/freebsd_socks.c1
-rwxr-xr-xpsutil/tests/test_system.py1
6 files changed, 33 insertions, 42 deletions
diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c
index 4e0e2d98..6b1e07d9 100644
--- a/psutil/_psutil_bsd.c
+++ b/psutil/_psutil_bsd.c
@@ -59,8 +59,6 @@
#include <netinet/in.h> // process open files/connections
#include <sys/un.h>
-#include "_psutil_common.h"
-
#ifdef __FreeBSD__
#include "arch/bsd/freebsd.h"
#include "arch/bsd/freebsd_socks.h"
diff --git a/psutil/_psutil_posix.h b/psutil/_psutil_posix.h
index bbe6fc5a..86708f4b 100644
--- a/psutil/_psutil_posix.h
+++ b/psutil/_psutil_posix.h
@@ -3,13 +3,3 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
-#include <Python.h>
-
-static PyObject* psutil_net_if_addrs(PyObject* self, PyObject* args);
-static PyObject* psutil_posix_getpriority(PyObject* self, PyObject* args);
-static PyObject* psutil_posix_setpriority(PyObject* self, PyObject* args);
-
-#if defined(__FreeBSD__) || defined(__APPLE__)
-static PyObject* psutil_net_if_stats(PyObject* self, PyObject* args);
-#endif
diff --git a/psutil/arch/bsd/freebsd.c b/psutil/arch/bsd/freebsd.c
index f7e15f75..96737851 100644
--- a/psutil/arch/bsd/freebsd.c
+++ b/psutil/arch/bsd/freebsd.c
@@ -67,6 +67,38 @@ psutil_kinfo_proc(const pid_t pid, struct kinfo_proc *proc) {
}
+/*
+ * Return 1 if PID exists in the current process list, else 0, -1
+ * on error.
+ * TODO: this should live in _psutil_posix.c but for some reason if I
+ * move it there I get a "include undefined symbol" error.
+ */
+int
+psutil_pid_exists(long pid) {
+ int ret;
+
+ if (pid < 0)
+ return 0;
+ if (pid == 0)
+ return 1;
+
+ ret = kill(pid , 0);
+ if (ret == 0)
+ return 1;
+ else {
+ if (errno == ESRCH)
+ return 0;
+ else if (errno == EPERM)
+ return 1;
+ else {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return -1;
+ }
+ }
+}
+
+
+
int
psutil_raise_ad_or_nsp(long pid) {
// Set exception to AccessDenied if pid exists else NoSuchProcess.
@@ -281,34 +313,6 @@ error:
/*
- * Return 1 if PID exists in the current process list, else 0, -1
- * on error.
- * TODO: this should live in _psutil_posix.c but for some reason if I
- * move it there I get a "include undefined symbol" error.
- */
-int
-psutil_pid_exists(long pid) {
- int ret;
- if (pid < 0)
- return 0;
- ret = kill(pid , 0);
- if (ret == 0)
- return 1;
- else {
- if (ret == ESRCH)
- return 0;
- else if (ret == EPERM)
- return 1;
- else {
- PyErr_SetFromErrno(PyExc_OSError);
- return -1;
- }
- }
-}
-
-
-
-/*
* Return process pathname executable.
* Thanks to Robert N. M. Watson:
* http://fxr.googlebit.com/source/usr.bin/procstat/procstat_bin.c?v=8-CURRENT
diff --git a/psutil/arch/bsd/freebsd.h b/psutil/arch/bsd/freebsd.h
index ad745ac9..09a2e9f2 100644
--- a/psutil/arch/bsd/freebsd.h
+++ b/psutil/arch/bsd/freebsd.h
@@ -8,7 +8,6 @@
typedef struct kinfo_proc kinfo_proc;
-static char *psutil_get_cmd_args(long pid, size_t *argsize);
int psutil_get_proc_list(struct kinfo_proc **procList, size_t *procCount);
int psutil_kinfo_proc(const pid_t pid, struct kinfo_proc *proc);
int psutil_pid_exists(long pid);
diff --git a/psutil/arch/bsd/freebsd_socks.c b/psutil/arch/bsd/freebsd_socks.c
index 8fe93db0..e26645af 100644
--- a/psutil/arch/bsd/freebsd_socks.c
+++ b/psutil/arch/bsd/freebsd_socks.c
@@ -26,7 +26,6 @@
#include <libutil.h>
#include "freebsd.h"
-#include "freebsd_socks.h"
#define HASHSIZE 1009
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index 2d7dbf05..281b217c 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -712,6 +712,7 @@ class TestSystemAPIs(unittest.TestCase):
assert psutil.BSD
self.assertEqual([psutil.FREEBSD, psutil.OPENBSD,
psutil.NETBSD].count(True), 1)
+ names.remove("BSD")
names.remove("FREEBSD")
names.remove("OPENBSD")
names.remove("NETBSD")