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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also, properly handle closed file descriptors in read_until_output_matches().

Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
---
 client/tests/kvm/kvm_subprocess.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

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
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux