From 22d6a7d40652eb92265cb03f2a719974e86bcb4f Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 1 Jul 2017 03:39:10 +0300 Subject: [PATCH] Fix(subproc.py): Carefully close file descriptors Use os.fdopen() to determine if a file descriptor is valid. --- subproc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subproc.py b/subproc.py index 57a9568..b5944f9 100755 --- a/subproc.py +++ b/subproc.py @@ -328,7 +328,11 @@ class Subprocess: (sig[0], self.pid, self.cmd, hex(id(self))[2:]))) for i in self.pipefiles: - os.close(i) + try: + fp = os.fdopen(i).close() + except OSError: + pass + del self.pipefiles[:] self.pid = 0 return None # ===> time.sleep(.1) -- 2.39.5