summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-12-03 16:54:43 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2017-12-03 16:54:43 +0100
commitdb6a589baf0ee75c908bcc02d96ff5227da291b0 (patch)
treed90118d8368612873b90cfbccc7945455e98f2e0
parenta4361cddd71a60c37ba00d6fca1f6e11e1217558 (diff)
downloadpsutil-db6a589baf0ee75c908bcc02d96ff5227da291b0.tar.gz
fix pid 0 bug
-rw-r--r--.travis.yml7
-rw-r--r--psutil/_psosx.py24
2 files changed, 15 insertions, 16 deletions
diff --git a/.travis.yml b/.travis.yml
index bac030d5..9289eb6b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,11 +4,18 @@ cache: pip
matrix:
include:
# Linux
+ - python: 2.6
- python: 2.7
+ - python: 3.4
+ - python: 3.5
+ - python: 3.6
# OSX
- language: generic
os: osx
env: PYVER=py27
+ - language: generic
+ os: osx
+ env: PYVER=py34
install:
- ./.ci/travis/install.sh
script:
diff --git a/psutil/_psosx.py b/psutil/_psosx.py
index 64b289fa..4c97af71 100644
--- a/psutil/_psosx.py
+++ b/psutil/_psosx.py
@@ -18,7 +18,6 @@ from . import _psutil_posix as cext_posix
from ._common import AF_INET6
from ._common import conn_tmap
from ._common import isfile_strict
-from ._common import memoize
from ._common import memoize_when_activated
from ._common import parse_environ_block
from ._common import sockfam_to_enum
@@ -302,27 +301,20 @@ def users():
# =====================================================================
-@memoize
-def _add_pid_0(pids):
- # On certain OSX versions pids() C implementation does not return
- # PID 0 but "ps" does and the process is querable via sysctl().
- if 0 in pids:
- return False
- else:
+def pids():
+ ls = cext.pids()
+ if 0 not in ls:
+ # On certain OSX versions pids() C doesn't return PID 0 but
+ # "ps" does and the process is querable via sysctl():
+ # https://travis-ci.org/giampaolo/psutil/jobs/309619941
try:
Process(0).create_time()
except NoSuchProcess:
return False
except AccessDenied:
- return True
+ ls.append(0)
else:
- return True
-
-
-def pids():
- ls = cext.pids()
- if _add_pid_0(ls):
- ls.append(0)
+ ls.append(0)
return ls