From 99b0753bf2d009f31229a82a1127712acadf921b Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Wed, 12 Apr 2023 16:32:40 +0200 Subject: [PATCH 1/2] OpenBSD is unable to recognize zombie process. See 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) ---------------------------------------------------------------------- Ran 1 test in 0.136s FAILED (errors=1) --- psutil/_psbsd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index a25c96cd4..a0f07ee23 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -545,7 +545,7 @@ def pid_exists(pid): 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 From f6e13b693ac267f7a248f58d690adc9b8a487255 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Wed, 12 Apr 2023 16:36:23 +0200 Subject: [PATCH 2/2] update HISTORY --- HISTORY.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index ac50e8979..e82605d8a 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 =====