<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 21, 2021 at 7:30 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
> This 'pid' is the parent shell process id, so it obviously that<br>
> tst_timeout_kill<br>
> process would get signal SIGTERM as well.<br>
> <br>
> I'm thinking maybe we should let tst_timeout_kill itself ignore SIGTERM<br>
> otherwise we have no chance to perform the following double-check code?<br>
<br>
I guess that signal(SIGTERM, SIG_IGN) a the start of the main() should<br>
fix it.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">It works, but better put it behind of sleep(timeout). </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Because we still need to guarantee tst_timeout_kill can be </div><div class="gmail_default" style="font-size:small">stopped by _tst_cleanup_timer before timeout happening.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--- a/testcases/lib/tst_timeout_kill.c<br>+++ b/testcases/lib/tst_timeout_kill.c<br>@@ -44,6 +44,8 @@ int main(int argc, char *argv[])<br>        if (timeout)<br>                sleep(timeout);<br> <br>+       signal(SIGTERM, SIG_IGN);<br>+<br>        print_msg("Test timed out, sending SIGTERM!");<br>        print_msg("If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1");<br> <br>@@ -57,12 +59,12 @@ int main(int argc, char *argv[])<br> <br>        i = 10;<br> <br>-       while (!kill(-pid, 0) && i-- > 0) {<br>+       while (!kill(pid, 0) && i-- > 0) {<br>                print_msg("Test is still running...");<br>                sleep(1);<br>        }<br> <br>-       if (!kill(-pid, 0)) {<br>+       if (!kill(pid, 0)) {<br>                print_msg("Test is still running, sending SIGKILL");<br>                ret = kill(-pid, SIGKILL);<br>                if (ret) {<br></div><div class="gmail_default" style="font-size:small"><br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>