summaryrefslogtreecommitdiff
path: root/psutil/_psutil_bsd.c
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-14 14:17:46 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-05-14 14:17:46 +0200
commitfd2205bad09db0efab8958c359897fc1772dc187 (patch)
tree6995421283aa099d3d2674c1e999fcfd6938933f /psutil/_psutil_bsd.c
parent06ded749e398c1dbec32548302d73b2832b1c5a2 (diff)
downloadpsutil-fd2205bad09db0efab8958c359897fc1772dc187.tar.gz
fix #1069 / freebsd: cpu_num() may return 255; now returns -1
Diffstat (limited to 'psutil/_psutil_bsd.c')
-rw-r--r--psutil/_psutil_bsd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c
index 6478cc65..03bdd94f 100644
--- a/psutil/_psutil_bsd.c
+++ b/psutil/_psutil_bsd.c
@@ -197,7 +197,7 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
long memtext;
long memdata;
long memstack;
- unsigned char oncpu;
+ int oncpu;
kinfo_proc kp;
long pagesize = sysconf(_SC_PAGESIZE);
char str[1000];
@@ -252,6 +252,7 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
// 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
+ // XXX - note: for "intr" PID this is -1.
if (kp.ki_stat == SRUN && kp.ki_oncpu != NOCPU)
oncpu = kp.ki_oncpu;
else
@@ -300,7 +301,7 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
memdata, // (long) mem data
memstack, // (long) mem stack
// others
- oncpu, // (unsigned char) the CPU we are on
+ oncpu, // (int) the CPU we are on
#elif defined(PSUTIL_OPENBSD) || defined(PSUTIL_NETBSD)
//
(long)kp.p_ppid, // (long) ppid
@@ -336,7 +337,7 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
memdata, // (long) mem data
memstack, // (long) mem stack
// others
- oncpu, // (unsigned char) the CPU we are on
+ oncpu, // (int) the CPU we are on
#endif
py_name // (pystr) name
);