Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore zombie processes on termination #118

Merged
merged 2 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Upcoming
--------

- Ignore zombie processes which are erroneously considered alive with python 3.11
(`#117 <https://github.com/pytest-dev/pytest-xprocess/issues/117>`_)

0.21.0 (2022-11-27)
-------------------

Expand Down
2 changes: 2 additions & 0 deletions xprocess/xprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ def terminate(self, *, kill_proc_tree=True, timeout=20):
for p in reversed(kill_list):
self._signal_process(p, signal.SIGTERM)
_, alive = psutil.wait_procs(kill_list, timeout=timeout)
alive = [a for a in alive if a.status() != psutil.STATUS_ZOMBIE]

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

# even if termination itself fails,
# the signal has been sent to the process
Expand Down