Signed-off-by: Michael Goldish <[email protected]>
---
client/tests/kvm/kvm_utils.py | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index f046810..f686a53 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -265,6 +265,23 @@ def safe_kill(pid, signal):
return False
+def kill_process_tree(pid, sig=signal.SIGKILL):
+ """Signal a process and all of its children.
+
+ If the process does not exist -- return.
+
+ @param pid: The pid of the process to signal.
+ @param sig: The signal to send to the processes.
+ """
+ if not safe_kill(pid, signal.SIGSTOP):
+ return
+ children = commands.getoutput("ps --ppid=%d -o pid=" % pid).split()
+ for child in children:
+ kill_process_tree(int(child), sig)
+ safe_kill(pid, sig)
+ safe_kill(pid, signal.SIGCONT)
+
+
def get_latest_kvm_release_tag(release_dir):
"""
Fetches the latest release tag for KVM.
--
1.5.4.1
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html