Skip to content

Commit b716741

Browse files
authored
Ignore zombie processes on termination (#118)
* Ignore zombie processes on termination Fixes #117 * Add CHANGELOG entry
1 parent b5c8239 commit b716741

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Upcoming
2+
--------
3+
4+
- Ignore zombie processes which are erroneously considered alive with python 3.11
5+
(`#117 <https://github.com/pytest-dev/pytest-xprocess/issues/117>`_)
6+
17
0.21.0 (2022-11-27)
28
-------------------
39

xprocess/xprocess.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ def terminate(self, *, kill_proc_tree=True, timeout=20):
8383
for p in reversed(kill_list):
8484
self._signal_process(p, signal.SIGTERM)
8585
_, alive = psutil.wait_procs(kill_list, timeout=timeout)
86+
alive = [a for a in alive if a.status() != psutil.STATUS_ZOMBIE]
8687

8788
# forcefully terminate procs still running
8889
for p in alive:
8990
self._signal_process(p, signal.SIGKILL)
9091
_, alive = psutil.wait_procs(kill_list, timeout=timeout)
92+
alive = [a for a in alive if a.status() != psutil.STATUS_ZOMBIE]
9193

9294
# even if termination itself fails,
9395
# the signal has been sent to the process

0 commit comments

Comments
 (0)