diff --git a/HISTORY.rst b/HISTORY.rst index 8f49025b7..f69c5fb63 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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 ===== diff --git a/psutil/__init__.py b/psutil/__init__.py index 2ecd3bddf..5e9a7fb6c 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -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 @@ -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 diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 78c03d5c5..b197dba33 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -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')')