diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-01-23 23:06:30 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-01-23 23:06:30 +0100 |
commit | 5f186957a4ae6505810488c7b3118453c459fdec (patch) | |
tree | 43ee8a0811724b2d6bbd267808ee49b3becf08f6 /psutil/_psbsd.py | |
parent | 29496900f772c8c594fa9c5142a88a5291c05f55 (diff) | |
parent | f8c07ae1082ee07fd08c25fa163fc8edb31e5b7f (diff) | |
download | psutil-5f186957a4ae6505810488c7b3118453c459fdec.tar.gz |
merge from master
Diffstat (limited to 'psutil/_psbsd.py')
-rw-r--r-- | psutil/_psbsd.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index 0a14bf80..022f5758 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -17,6 +17,7 @@ from . import _psutil_bsd as cext from . import _psutil_posix as cext_posix from ._common import conn_tmap from ._common import FREEBSD +from ._common import memoize from ._common import memoize_when_activated from ._common import NETBSD from ._common import OPENBSD @@ -421,7 +422,26 @@ def users(): # ===================================================================== -pids = cext.pids +@memoize +def _pid_0_exists(): + try: + Process(0).name() + except NoSuchProcess: + return False + except AccessDenied: + return True + else: + return True + + +def pids(): + ret = cext.pids() + if OPENBSD and (0 not in ret) and _pid_0_exists(): + # On OpenBSD the kernel does not return PID 0 (neither does + # ps) but it's actually querable (Process(0) will succeed). + ret.insert(0, 0) + return ret + if OPENBSD or NETBSD: def pid_exists(pid): |