summaryrefslogtreecommitdiff
path: root/psutil
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-11-26 02:27:01 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2016-11-26 02:27:01 +0100
commit4b52141bd4f7c477d4ad3c36142ebeddb92eab18 (patch)
tree4d1ff4f016bccdc4f0b5fcf767dacbc5cb8f2607 /psutil
parentd7aed98564993694d55d95a0b034fcb62afafaea (diff)
downloadpsutil-4b52141bd4f7c477d4ad3c36142ebeddb92eab18.tar.gz
#357: does not support cpu_num() on Net and Open BSD
Diffstat (limited to 'psutil')
-rw-r--r--psutil/_psbsd.py7
-rw-r--r--psutil/_psutil_bsd.c8
2 files changed, 12 insertions, 3 deletions
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py
index 7cb9f2cd..0a14bf80 100644
--- a/psutil/_psbsd.py
+++ b/psutil/_psbsd.py
@@ -590,9 +590,10 @@ class Process(object):
rawtuple[kinfo_proc_map['ch_user_time']],
rawtuple[kinfo_proc_map['ch_sys_time']])
- @wrap_exceptions
- def cpu_num(self):
- return self.oneshot()[kinfo_proc_map['cpunum']]
+ if FREEBSD:
+ @wrap_exceptions
+ def cpu_num(self):
+ return self.oneshot()[kinfo_proc_map['cpunum']]
@wrap_exceptions
def memory_info(self):
diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c
index 48391279..b1bce487 100644
--- a/psutil/_psutil_bsd.c
+++ b/psutil/_psutil_bsd.c
@@ -258,6 +258,7 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
memstack = (long)kp.p_vm_ssize * pagesize;
#endif
+#ifdef __FreeBSD__
// what CPU we're on; top was used as an example:
// https://svnweb.freebsd.org/base/head/usr.bin/top/machine.c?
// view=markup&pathrev=273835
@@ -265,6 +266,13 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
oncpu = kp.ki_oncpu;
else
oncpu = kp.ki_lastcpu;
+#else
+ // On Net/OpenBSD we have kp.p_cpuid but it appears it's always
+ // set to KI_NOCPU. Even if it's not, ki_lastcpu does not exist
+ // so there's no way to determine where "sleeping" processes
+ // were. Not supported.
+ oncpu = -1;
+#endif
// Return a single big tuple with all process info.
py_retlist = Py_BuildValue(