public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] lib/tst_test.c: Bugfix for heartbeat
Date: Mon, 12 Apr 2021 17:10:11 +0200	[thread overview]
Message-ID: <YHRi0457Zo5s7sUx@yuki> (raw)
In-Reply-To: <20210323135604.24504-1-zhaogongyi@huawei.com>

Hi!
> When main process has been killed, its son process will be reaped by
> init, and son process will send SIGUSR1 to the init process.
> 
> In busybox, send SIGUSR1 to the init process will trigger shutdown.
> 
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
>  lib/tst_test.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 45753d1ca..91dfc6bf9 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1156,7 +1156,15 @@ static void heartbeat(void)
>  	if (tst_clock_gettime(CLOCK_MONOTONIC, &tst_start_time))
>  		tst_res(TWARN | TERRNO, "tst_clock_gettime() failed");
> 
> -	kill(getppid(), SIGUSR1);
> +	if (getppid() == 1) {
> +		tst_res(TFAIL, "Main test process might have exit!");
                         ^
			 This should be TBROK I guess.
> +		/*
> +		 * We need kill the task group immediately since the
> +		 * main process has exit.
> +		 */
> +		kill(0, SIGKILL);

Shouldn't we call exit here? There is no point in continuing once we
reached this point.

> +	} else
> +		kill(getppid(), SIGUSR1);
>  }
> 
>  static void testrun(void)
> --
> 2.17.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2021-04-12 15:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 13:56 [LTP] [PATCH] lib/tst_test.c: Bugfix for heartbeat Zhao Gongyi
2021-04-12 15:10 ` Cyril Hrubis [this message]
2021-04-15  7:52 ` Petr Vorel
2021-04-15 11:31   ` Cyril Hrubis
2021-04-15 14:03     ` Petr Vorel
  -- strict thread matches above, loose matches on Subject: below --
2021-04-13  6:42 zhaogongyi
2021-04-13  7:42 ` Cyril Hrubis
2021-04-13  8:19 zhaogongyi
2021-04-13  9:37 ` Cyril Hrubis
2021-04-13 10:52 zhaogongyi
2021-04-13 11:32 ` Cyril Hrubis
2021-04-13 11:54 Zhao Gongyi
2021-04-15 11:32 ` Cyril Hrubis
2021-04-15 14:05   ` Cyril Hrubis
2021-04-13 11:54 zhaogongyi
2021-04-15 12:11 zhaogongyi
2021-04-15 13:58 ` Petr Vorel

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=YHRi0457Zo5s7sUx@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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