From patchwork Wed Nov 4 14:05:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 57585 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA4E8U3I020616 for ; Wed, 4 Nov 2009 14:08:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756312AbZKDOIX (ORCPT ); Wed, 4 Nov 2009 09:08:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756328AbZKDOIW (ORCPT ); Wed, 4 Nov 2009 09:08:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45165 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756312AbZKDOIW (ORCPT ); Wed, 4 Nov 2009 09:08:22 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA4E8RMP008332; Wed, 4 Nov 2009 09:08:27 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA4E8Qff004817; Wed, 4 Nov 2009 09:08:27 -0500 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id nA4E897D029198; Wed, 4 Nov 2009 09:08:24 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 5/6] KVM test: kvm_subprocess.py: avoid double-closing file descriptors Date: Wed, 4 Nov 2009 16:05:41 +0200 Message-Id: <1257343542-27902-5-git-send-email-mgoldish@redhat.com> In-Reply-To: <1257343542-27902-4-git-send-email-mgoldish@redhat.com> References: <1257343542-27902-1-git-send-email-mgoldish@redhat.com> <1257343542-27902-2-git-send-email-mgoldish@redhat.com> <1257343542-27902-3-git-send-email-mgoldish@redhat.com> <1257343542-27902-4-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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