From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Wang Date: Thu, 13 May 2021 13:08:40 +0800 Subject: [LTP] [PATCH v3 3/4] lib: ignore SIGINT in _tst_kill_test In-Reply-To: References: <20210508055109.16914-4-liwang@redhat.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ltp@lists.linux.it > 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? 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 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 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 tst_res TBROK "Test still running, sending SIGKILL" kill -KILL -$pid fi -- Regards, Li Wang