diff mbox

[KVM-AUTOTEST,5/6] KVM test: kvm_subprocess.py: avoid double-closing file descriptors

Message ID 1257343542-27902-5-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Nov. 4, 2009, 2:05 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
index 859aa2b..9222d33 100755
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -497,6 +497,7 @@  class kvm_spawn:
                 os.close(fd)
             except:
                 pass
+        self.reader_fds = {}
         # Remove all used files
         for filename in (_get_filenames("/tmp/kvm_spawn", self.id) +
                          self.reader_filenames.values()):
@@ -861,9 +862,13 @@  class kvm_expect(kvm_tail):
         fd = self._get_fd("expect")
         end_time = time.time() + timeout
         while True:
-            r, w, x = select.select([fd], [], [],
-                                    max(0, end_time - time.time()))
-            if fd not in r: break
+            try:
+                r, w, x = select.select([fd], [], [],
+                                        max(0, end_time - time.time()))
+            except (select.error, TypeError):
+                break
+            if fd not in r:
+                break
             # Read data from child
             newdata = self.read_nonblocking(internal_timeout)
             # Print it if necessary