From 7f3c1e5878d16e8f309feaab3ea9fdbadde32b3c Mon Sep 17 00:00:00 2001 From: Soumen Ghosh <soumeng@codeaurora.org> Date: Tue, 22 Jan 2019 12:43:03 -0800 Subject: [PATCH] lrdpv2: kill the process after QTF timeout. kill the qtf server forcefully after completion of qtf parsing. Here if QTF processed successfuly within timeout value then QTF sever will be closed gracefuly, but if it is not completed then forcefuly we have to kill the qtfserver and all child processes Change-Id: Ifac67357568eb2b5b4f73159176c257fcdafa9a6 --- linux-ramdump-parser-v2/debug_image_v2.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/linux-ramdump-parser-v2/debug_image_v2.py b/linux-ramdump-parser-v2/debug_image_v2.py index fe5634a..5b0f7cb 100644 --- a/linux-ramdump-parser-v2/debug_image_v2.py +++ b/linux-ramdump-parser-v2/debug_image_v2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. +# Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 and @@ -501,6 +501,7 @@ class DebugImage_v2(): [qtf_path, '-c', '{:d}'.format(port),'new workspace {0} {1} {2}'.format(qtf_dir, chipset, hlos)], shell=True,stderr=subprocess.PIPE,stdout=subprocess.PIPE) server_proc1.communicate() self.collect_ftrace_format(ram_dump) + server_proc1.kill() p = subprocess.Popen('{0} -c {1} open workspace {2}'.format(qtf_path, port, workspace)) self.wait_for_completion_timeout(p,60) @@ -512,7 +513,23 @@ class DebugImage_v2(): self.wait_for_completion_timeout(p,60) p = subprocess.Popen('{0} -c {1} exit'.format(qtf_path, port)) self.wait_for_completion_timeout(p,60) - server_proc.terminate() + try: + import psutil + pid = server_proc.pid + pid = int(pid) + parent = psutil.Process(pid) + for child in parent.children(recursive=True): # or parent.children() for recursive=False + print_out_str("child process = {0} which needs to be killed forcefully after QTF timeout".format(child)) + if (psutil.pid_exists(child.pid)): + try: + child.kill() + except Exception as e: + print_out_str("Error: {0} while killing the child of QTF process".format(e)) + pass + server_proc.kill() + except Exception as e1: + print_out_str("psutil module import error = {0}".format(e1)) + pass def parse_dcc(self, ram_dump): out_dir = ram_dump.outdir -- GitLab