Skip to content

Commit

Permalink
fix: handle process shutdown with limited permissions (#51)
Browse files Browse the repository at this point in the history
Certain platforms like Android do not have permission to list all child
processes. In this instance, just continue
  • Loading branch information
dead10ck authored Oct 17, 2024
1 parent 0631d41 commit fcf6311
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pytestshellutils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def init_terminal(
except subprocess.TimeoutExpired:
# We're good
# Collect any child processes, though, this early there likely is none
with contextlib.suppress(psutil.NoSuchProcess):
with contextlib.suppress(psutil.NoSuchProcess, psutil.AccessDenied):
for child in psutil.Process(self._terminal.pid).children(
recursive=True
): # pragma: no cover
Expand Down Expand Up @@ -221,7 +221,7 @@ def _terminate(self) -> ProcessResult:
atexit.unregister(self.terminate)
log.info("Stopping %s", self.factory)
# Collect any child processes information before terminating the process
with contextlib.suppress(psutil.NoSuchProcess):
with contextlib.suppress(psutil.NoSuchProcess, psutil.AccessDenied):
for child in psutil.Process(self._terminal.pid).children(recursive=True):
if child not in self._children:
self._children.append(child)
Expand Down

0 comments on commit fcf6311

Please sign in to comment.