summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2023-04-12 16:37:41 +0200
committerGitHub <noreply@github.com>2023-04-12 16:37:41 +0200
commite6b1659df484bd2709d09f62b52851424630c200 (patch)
tree5d5915c9ca2bbbebd374ff2323918a232922442b
parent501e636bdb946a18f94a72941212417b53b5dbbe (diff)
downloadpsutil-e6b1659df484bd2709d09f62b52851424630c200.tar.gz
OpenBSD is unable to recognize zombie process. (#2229)
OpenBSD is unable to recognize zombie process. It will raise NoSuchProcess instead of ZombieProcess. Test failure: ====================================================================== ERROR: psutil.tests.test_process.TestProcess.test_zombie_process ---------------------------------------------------------------------- Traceback (most recent call last): File "/vagrant/psutil/psutil/_psbsd.py", line 560, in wrapper return fun(self, *args, **kwargs) File "/vagrant/psutil/psutil/_psbsd.py", line 862, in open_files rawlist = cext.proc_open_files(self.pid) ProcessLookupError: [Errno 3] No such process During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/vagrant/psutil/psutil/tests/test_process.py", line 1312, in test_zombie_process zproc.as_dict() File "/vagrant/psutil/psutil/__init__.py", line 528, in as_dict ret = meth() File "/vagrant/psutil/psutil/__init__.py", line 1142, in open_files return self._proc.open_files() File "/vagrant/psutil/psutil/_psbsd.py", line 565, in wrapper raise NoSuchProcess(self.pid, self._name) psutil.NoSuchProcess: process no longer exists (pid=67013) This happens because OpenBSD is the only BSD defining 2 codes for zombie processes: # According to /usr/include/sys/proc.h SZOMB is unused. # test_zombie_process() shows that SDEAD is the right # equivalent. Also it appears there's no equivalent of # psutil.STATUS_DEAD. SDEAD really means STATUS_ZOMBIE. # cext.SZOMB: _common.STATUS_ZOMBIE, cext.SDEAD: _common.STATUS_ZOMBIE, cext.SZOMB: _common.STATUS_ZOMBIE,
-rw-r--r--HISTORY.rst2
-rw-r--r--psutil/_psbsd.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index ac50e897..e82605d8 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -25,6 +25,8 @@
Matthieu Darbois)
- 2225_, [POSIX]: `users()`_ loses precision for ``started`` attribute (off by
1 minute).
+- 2229_, [OpenBSD]: unable to properly recognize zombie processes.
+ `NoSuchProcess`_ may be raised instead of `ZombieProcess`_.
5.9.4
=====
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py
index a25c96cd..a0f07ee2 100644
--- a/psutil/_psbsd.py
+++ b/psutil/_psbsd.py
@@ -545,7 +545,7 @@ else:
def is_zombie(pid):
try:
st = cext.proc_oneshot_info(pid)[kinfo_proc_map['status']]
- return st == cext.SZOMB
+ return PROC_STATUSES.get(st) == _common.STATUS_ZOMBIE
except Exception:
return False