diff --git a/pupy/packages/linux/all/ptyshell.py b/pupy/packages/linux/all/ptyshell.py index e8c2c8f7..3312e2a2 100644 --- a/pupy/packages/linux/all/ptyshell.py +++ b/pupy/packages/linux/all/ptyshell.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2015, Nicolas VERDIER (contact@n1nj4.eu) # Pupy is under the BSD 3-Clause license. see the LICENSE file at the root of the project for the detailed licence terms + import sys import os import os.path @@ -25,8 +26,19 @@ class PtyShell(object): self.real_stdout = sys.stdout def close(self): - if self.prog is not None and self.prog.returncode is None: - self.prog.terminate() + if self.prog is not None: + self.prog.poll() + + if self.prog.returncode is None: + try: + self.prog.terminate() + except: + pass + + try: + self.prog.poll() + except: + pass def __del__(self): self.close()