]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(subproc.py): Carefully close file descriptors
authorOleg Broytman <phd@phdru.name>
Sat, 1 Jul 2017 00:39:10 +0000 (03:39 +0300)
committerOleg Broytman <phd@phdru.name>
Sat, 1 Jul 2017 00:39:10 +0000 (03:39 +0300)
Use os.fdopen() to determine if a file descriptor is valid.

subproc.py

index 57a95682803fcd83bd00d554c8d55784af3cef15..b5944f90f87a8c1a9a5536c267ebd1d1b87e4f72 100755 (executable)
@@ -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)