public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] Allow graceful subtest cleanup in shell tests
Date: Mon, 14 Nov 2022 11:56:56 +0000	[thread overview]
Message-ID: <877czxu4ku.fsf@suse.de> (raw)
In-Reply-To: <20221110135442.14501-1-mdoucha@suse.cz>

Hello,

Martin Doucha <mdoucha@suse.cz> writes:

> The new shell test timeout code sends SIGTERM to any subprocesses when
> the main script hits timeout. SIGTERM isn't handled by the LTP library
> which means that tools like netstress will be instantly killed without
> performing any cleanup. Handle SIGTERM like SIGINT in LTP library
> to allow graceful cleanup.
>
> Signed-off-by: Martin Doucha <mdoucha@suse.cz>

Merged with Petr's tag, thanks!

Possibly we should also print the signal that we received somehow.

> ---
>
> Note: The current lack of graceful cleanup causes random failures in shell
> tests which run the same tool many times (e.g. netstress). When the PID
> counter wraps around and the tool accidentally gets the same PID as another
> process that got killed by SIGTERM, the new test process will fail during IPC
> setup.
>
>  lib/tst_test.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index b225ba082..1732fd058 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1568,6 +1568,7 @@ static int fork_testrun(void)
>  	int status;
>  
>  	SAFE_SIGNAL(SIGINT, sigint_handler);
> +	SAFE_SIGNAL(SIGTERM, sigint_handler);
>  
>  	alarm(results->timeout);
>  
> @@ -1579,6 +1580,7 @@ static int fork_testrun(void)
>  		tst_disable_oom_protection(0);
>  		SAFE_SIGNAL(SIGALRM, SIG_DFL);
>  		SAFE_SIGNAL(SIGUSR1, SIG_DFL);
> +		SAFE_SIGNAL(SIGTERM, SIG_DFL);
>  		SAFE_SIGNAL(SIGINT, SIG_DFL);
>  		SAFE_SETPGID(0, 0);
>  		testrun();
> @@ -1586,6 +1588,7 @@ static int fork_testrun(void)
>  
>  	SAFE_WAITPID(test_pid, &status, 0);
>  	alarm(0);
> +	SAFE_SIGNAL(SIGTERM, SIG_DFL);
>  	SAFE_SIGNAL(SIGINT, SIG_DFL);
>  
>  	if (tst_test->taint_check && tst_taint_check()) {
> -- 
> 2.37.3


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      parent reply	other threads:[~2022-11-14 12:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 13:54 [LTP] [PATCH] Allow graceful subtest cleanup in shell tests Martin Doucha
2022-11-11 14:02 ` Petr Vorel
2022-11-14 11:56 ` Richard Palethorpe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877czxu4ku.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=ltp@lists.linux.it \
    --cc=mdoucha@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox