[Fuego] [fuego-core 2/7] ftc: fix test process is not killed when fuego test times out

[email protected] Sun, 18 Jul 2021 16:40:07 +0530
Newsgroups dev.linux.lists.fuego
Message-ID <[email protected]>
From: nguyen thi huong <[email protected]>

- Currently, fuego kill main process and does not kill test process when test times out
  In that case, test process still runs but fuego test result is not available
- Revise implementation to kill all test processes and printout the result

Signed-off-by: nguyen thi huong <[email protected]>
Signed-off-by: venkata pyla <[email protected]>
---
 scripts/ftc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/ftc b/scripts/ftc
index 2a6a640..5c300d0 100755
--- a/scripts/ftc
+++ b/scripts/ftc
@@ -3914,7 +3914,7 @@ def ftc_exec_command(command, timeout):
 
     dprint("ftc_exec_command: command=%s" % command)
 
-    p = subprocess.Popen(command.split(), stdout=log, stderr=log)
+    p = subprocess.Popen(command.split(), stdout=log, stderr=log, preexec_fn=os.setpgrp)
 
     # specify timeout for command operation
     signal.signal(signal.SIGALRM, alarm_handler)
@@ -3960,7 +3960,8 @@ def ftc_exec_command(command, timeout):
         #    p.kill()
 
         # abort with prejudice...
-        p.kill()
+        pgrp = os.getpgid(p.pid)
+        os.killpg(pgrp, signal.SIGALRM)
         timed_out = True
 
     finally:
-- 
2.20.1