All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 3/4] lib: ignore SIGINT in _tst_kill_test
Date: Fri, 14 May 2021 09:53:43 +0200	[thread overview]
Message-ID: <YJ4sh7zBOZxQy1S0@pevik> (raw)
In-Reply-To: <CAEemH2fRLqipQWTxVsakYNGsmQT+2X8_xzgepCiAY1O8YWtKFA@mail.gmail.com>

> > FYI I tried to use both SIGINT and SIGTERM, but there was some problem.
> > But I guess it was my error. Please *add* SIGTERM (keep SIGINT).

> Yes, we'd better keep SIGINT for ctrl^c action and use SIGTERM
> additionally for process terminating.

> Does this below (rough solution in my mind) work for you?
LGTM, but Joerg, Metan, could you please have a look?

> diff --git a/lib/newlib_tests/shell/timeout03.sh
> b/lib/newlib_tests/shell/timeout03.sh
> index cd548d9a2..f39f5712a 100755
> --- a/lib/newlib_tests/shell/timeout03.sh
> +++ b/lib/newlib_tests/shell/timeout03.sh
> @@ -30,6 +30,7 @@ TST_TIMEOUT=1

>  do_test()
>  {
> +       trap "echo 'Sorry, timeout03 is still alive'" TERM
Any reason why not use tst_res TINFO? (working on bash).
>         tst_res TINFO "testing killing test after TST_TIMEOUT"

>         sleep 2
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index 28c2052d6..d7c9791e9 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -21,7 +21,7 @@ export TST_LIB_LOADED=1
>  . tst_security.sh

>  # default trap function
> -trap "tst_brk TBROK 'test interrupted or timed out'" INT
> +trap "tst_brk TBROK 'test interrupted'" INT

>  _tst_do_exit()
>  {
> @@ -439,18 +439,18 @@ _tst_kill_test()
>  {
>         local i=10

> -       trap '' INT
> -       tst_res TBROK "Test timeouted, sending SIGINT! If you are
> running on slow machine, try exporting LTP_TIMEOUT_MUL > 1"
> -       kill -INT -$pid
> +       trap '' TERM
> +       tst_res TBROK "Test timeouted, sending SIGTERM! If you are
> running on slow machine, try exporting LTP_TIMEOUT_MUL > 1"
> +       kill -TERM -$pid
>         tst_sleep 100ms

> -       while kill -0 $pid 2>&1 > /dev/null && [ $i -gt 0 ]; do
> +       while kill -0 $pid &>/dev/null && [ $i -gt 0 ]; do
FYI: &> is a bashism (we need to keep the original).
>                 tst_res TINFO "Test is still running, waiting ${i}s"
>                 sleep 1
>                 i=$((i-1))
>         done

> -       if kill -0 $pid 2>&1 > /dev/null; then
> +       if kill -0 $pid &>/dev/null; then
And here as well.

>                 tst_res TBROK "Test still running, sending SIGKILL"
>                 kill -KILL -$pid
>         fi

Kind regards,
Petr

  reply	other threads:[~2021-05-14  7:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-08  5:51 [LTP] [PATCH v3 3/4] lib: ignore SIGINT in _tst_kill_test Li Wang
2021-05-10 11:47 ` Cyril Hrubis
2021-05-11  5:54 ` Joerg Vehlow
2021-05-12  9:49   ` Li Wang
2021-05-12 10:34     ` Joerg Vehlow
2021-05-12 14:20     ` Petr Vorel
2021-05-13  5:08       ` Li Wang
2021-05-14  7:53         ` Petr Vorel [this message]
2021-05-14  9:10           ` Li Wang
2021-05-14 15:10             ` Petr Vorel
2021-05-18  4:57         ` Joerg Vehlow
2021-05-18  7:27           ` Li Wang
2021-05-18  8:46             ` Petr Vorel
2021-05-18  9:45             ` Joerg Vehlow
2021-05-18 12:01               ` Li Wang

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=YJ4sh7zBOZxQy1S0@pevik \
    --to=pvorel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.