From patchwork Wed Sep 9 18:11:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 46427 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 n89IFdH3019137 for ; Wed, 9 Sep 2009 18:15:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753943AbZIISPb (ORCPT ); Wed, 9 Sep 2009 14:15:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753919AbZIISPb (ORCPT ); Wed, 9 Sep 2009 14:15:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13268 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753654AbZIISP3 (ORCPT ); Wed, 9 Sep 2009 14:15:29 -0400 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 n89IFVU4014748; Wed, 9 Sep 2009 14:15:32 -0400 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 n89IFVY0016629; Wed, 9 Sep 2009 14:15:31 -0400 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 n89IFNFQ012008; Wed, 9 Sep 2009 14:15:30 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [PATCH 05/19] KVM test: kvm_subprocess: use kill_process_tree() to close child processes Date: Wed, 9 Sep 2009 21:11:58 +0300 Message-Id: <1252519932-30733-5-git-send-email-mgoldish@redhat.com> In-Reply-To: <1252519932-30733-4-git-send-email-mgoldish@redhat.com> References: <1252519932-30733-1-git-send-email-mgoldish@redhat.com> <1252519932-30733-2-git-send-email-mgoldish@redhat.com> <1252519932-30733-3-git-send-email-mgoldish@redhat.com> <1252519932-30733-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 This is safer than just killing the session leader because some processes seem to remain alive after their session leader has exited. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_subprocess.py | 7 ++----- client/tests/kvm/kvm_vm.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py index 07303a8..ba61a8c 100755 --- a/client/tests/kvm/kvm_subprocess.py +++ b/client/tests/kvm/kvm_subprocess.py @@ -367,7 +367,7 @@ class kvm_spawn: return _locked(self.lock_server_running_filename) - def close(self, sig=signal.SIGTERM): + def close(self, sig=signal.SIGKILL): """ Kill the child process if it's alive and remove temporary files. @@ -375,10 +375,7 @@ class kvm_spawn: """ # Kill it if it's alive if self.is_alive(): - try: - os.kill(self.get_shell_pid(), sig) - except: - pass + kvm_utils.kill_process_tree(self.get_shell_pid(), sig) # Wait for the server to exit _wait(self.lock_server_running_filename) # Call all cleanup routines diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index bd7e0fc..79ca81d 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -541,7 +541,7 @@ class VM: # If the VM isn't dead yet... logging.debug("Cannot quit normally; sending a kill to close the " "deal...") - kvm_utils.safe_kill(self.process.get_pid(), 9) + kvm_utils.kill_process_tree(self.process.get_pid(), 9) # Wait for the VM to be really dead if kvm_utils.wait_for(self.is_dead, 5, 0.5, 0.5): logging.debug("VM is down")