unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <codonell@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH] support: Kill process group for test failure
Date: Thu, 20 Feb 2020 09:53:01 -0500	[thread overview]
Message-ID: <35c4ad7a-a55c-1b97-5568-c21ec93a0fd2@redhat.com> (raw)
In-Reply-To: <20200220143406.4768-1-adhemerval.zanella@linaro.org>

On 2/20/20 9:34 AM, Adhemerval Zanella wrote:
> Some testcases that create multiple subprocesses might abort or exit
> prior waiting for their children.  In such case, support_test_main
> does not try to kill the spawned test process group (as in the
> test timeout case).
> 
> On example that we are observing in internal tests is when
> malloc/tst-mallocfork2 fails to fork in the signal handling (due
> either maximum number of process or other non expected failure).
> 
> This patch kill the process group in the case of failed execution,
> similar on how it is done on timeout.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 
> Checked on x86_64-linux-gnu.
> ---
>  support/support_test_main.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/support/support_test_main.c b/support/support_test_main.c
> index e3f0bf15f2..ac9f710fb7 100644
> --- a/support/support_test_main.c
> +++ b/support/support_test_main.c
> @@ -459,6 +459,9 @@ support_test_main (int argc, char **argv, const struct test_config *config)
>    /* Process terminated normaly without timeout etc.  */
>    if (WIFEXITED (status))
>      {
> +      /* It is expected that a successful test execution handles all its
> +	 children.  */

OK.

> +
>        if (config->expected_status == 0)
>          {
>            if (config->expected_signal == 0)
> @@ -486,6 +489,10 @@ support_test_main (int argc, char **argv, const struct test_config *config)
>    /* Process was killed by timer or other signal.  */
>    else
>      {
> +      /* Kill the whole process group if test process aborts or exits prior
> +	 waiting for them.  */
> +      kill (-test_pid, SIGKILL);

OK. Send negation of process group id to kill the whole process group. The
process group id is the same as the id of the process that created the group
so test_pid is the right value.

Notes:
- Should we be using test_pgid to make this clear?
- Should this cleanup be refactored a bit to avoid duplication from
  signal_handler() and support_test_main() e.g. kill_process_group ()
  which runs kill looks for errors prints diagnostic etc.

> +
>        if (config->expected_signal == 0)
>          {
>            printf ("Didn't expect signal from child: got `%s'\n",
> 


-- 
Cheers,
Carlos.


  reply	other threads:[~2020-02-20 14:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20 14:34 [PATCH] support: Kill process group for test failure Adhemerval Zanella
2020-02-20 14:53 ` Carlos O'Donell [this message]
2020-02-20 15:14   ` Carlos O'Donell
2020-02-20 15:04 ` Florian Weimer
2020-02-20 15:12   ` Carlos O'Donell
2020-02-20 16:50     ` Adhemerval Zanella

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=35c4ad7a-a55c-1b97-5568-c21ec93a0fd2@redhat.com \
    --to=codonell@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).