Skip to content

Commit 6f136f1

Browse files
committed
corretta chiusura terminale locale
1 parent 5b0f733 commit 6f136f1

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

pyqt6/terminal_widget.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -471,25 +471,27 @@ def chiudi_processo(self):
471471
self._reader.wait(500)
472472
self._reader = None
473473

474-
if self._child_pid is not None:
475-
try:
476-
os.killpg(os.getpgid(self._child_pid), signal.SIGTERM)
477-
try:
478-
os.waitpid(self._child_pid, 0)
479-
except ChildProcessError:
480-
pass
481-
except (ProcessLookupError, OSError):
482-
pass
483-
self._child_pid = None
484-
self._process = None
485-
474+
# Chiude prima il master PTY: bash riceve EIO e termina senza aspettare
486475
if self._master is not None:
487476
try:
488477
os.close(self._master)
489478
except OSError:
490479
pass
491480
self._master = None
492481

482+
if self._child_pid is not None:
483+
try:
484+
os.killpg(os.getpgid(self._child_pid), signal.SIGKILL)
485+
except (ProcessLookupError, OSError):
486+
pass
487+
try:
488+
# WNOHANG: non blocca il main thread
489+
os.waitpid(self._child_pid, os.WNOHANG)
490+
except (ChildProcessError, OSError):
491+
pass
492+
self._child_pid = None
493+
self._process = None
494+
493495
if self._log_file is not None:
494496
try:
495497
self._log_file.close()

0 commit comments

Comments
 (0)