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

<[email protected]> Mon, 26 Jul 2021 08:29:20 +0000
Newsgroups dev.linux.lists.fuego
Message-ID <OSBPR01MB219745662E24C0F715A0198C9CE89@OSBPR01MB2197.jpnprd01.prod.outlook.com>
Dear Tim,

Thanks for your feedback.

The function handle timeout event so I think send SIGALARM is more reasonable.
Test driver or subprocesses will decide what to do with timeout signal.

For now, SIGALARM is trapped in fuego functions.sh
Signal handler will do post_tests and processing before exiting main process
When main process exit, all subprocesses that belong to group process will be exited.

Best Regards,
Huong
-----Original Message-----
From: [email protected] <[email protected]> 
Sent: Friday, July 23, 2021 1:35 AM
To: pyla venkata(TSIP) <[email protected]>
Cc: nguyen thi huong(TSDV Eng 1) <[email protected]>; sangorrin daniel(サンゴリン ダニエル □SWC◯ACT) <[email protected]>; [email protected]
Subject: RE: [fuego-core 2/7] ftc: fix test process is not killed when fuego test times out

OK - I have a question on this one.

> -----Original Message-----
> From: [email protected] <[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)

Why are you sending a SIGALARM instead of a SIGKILL?
This is a weaker signal, that can be ignored or masked.

>          timed_out = True
> 
>      finally:
> --
> 2.20.1
> 

I've applied this patch, but I'd like to know if you have some reason for weakening the signal sent to kill the process.

Thanks.
 -- Tim