From db6a589baf0ee75c908bcc02d96ff5227da291b0 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sun, 3 Dec 2017 16:54:43 +0100 Subject: fix pid 0 bug --- .travis.yml | 7 +++++++ psutil/_psosx.py | 24 ++++++++---------------- 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 -- cgit v1.2.1