Skip to content

Commit

Permalink
fix giampaolo#1274 / Process.children / Linux: do not swallow AccessD…
Browse files Browse the repository at this point in the history
…enied
  • Loading branch information
giampaolo committed May 8, 2018
1 parent 6ad3312 commit 1b5f8d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ XXXX-XX-XX

- 1273_: net_if_addr() namedtuple's name has been renamed from "snic" to
"snicaddr".
- 1274_: [Linux] there was a small chance Process.children() may swallow
AccessDenied exceptions.

5.4.5
=====
Expand Down
10 changes: 3 additions & 7 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
]
__all__.extend(_psplatform.__extra__all__)
__author__ = "Giampaolo Rodola'"
__version__ = "5.4.5"
__version__ = "5.4.6"
version_info = tuple([int(num) for num in __version__.split('.')])
AF_LINK = _psplatform.AF_LINK
POWER_TIME_UNLIMITED = _common.POWER_TIME_UNLIMITED
Expand Down Expand Up @@ -265,13 +265,9 @@ def _ppid_map():
ret = {}
for pid in pids():
try:
proc = _psplatform.Process(pid)
ppid = proc.ppid()
except (NoSuchProcess, AccessDenied):
# Note: AccessDenied is unlikely to happen.
ret[pid] = _psplatform.Process(pid).ppid()
except (NoSuchProcess, ZombieProcess):
pass
else:
ret[pid] = ppid
return ret


Expand Down
5 changes: 2 additions & 3 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,9 +1380,8 @@ def ppid_map():
data = f.read()
except EnvironmentError as err:
# Note: we should be able to access /stat for all processes
# so we won't bump into EPERM, which is good.
if err.errno not in (errno.ENOENT, errno.ESRCH,
errno.EPERM, errno.EACCES):
# aka it's unlikely we'll bump into EPERM, which is good.
if err.errno not in (errno.ENOENT, errno.ESRCH):
raise
else:
rpar = data.rfind(b')')
Expand Down

0 comments on commit 1b5f8d5

Please sign in to comment.