<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 Fri, Aug 21, 2020 at 10:22 AM Yang Xu <<a href="mailto:xuyang2018.jy@cn.fujitsu.com">xuyang2018.jy@cn.fujitsu.com</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"><span class="gmail_default" style="font-size:small">...</span><br>
>     Also, we can use the current process id but it may has unexpected<br>
>     result<br>
>     when kill succeed. So fork a child to test maybe a better solution.<br>
> <br>
> <br>
> Hmm, sorry for the uncleared description, actually I meant, to use real_pid<br>
> instead of the tc->child_flag directly, then start to reclaim the child <br>
> when the<br>
> real_pid test finishing.<br>
> <br>
> Does this below diff work for you?<br>
It looks well. But the real_pid only valid when the first sub test and <br>
the real pid is equals to 0 when using -i parameters because we have <br>
killed this children.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Yes, you're right. </div><div><div class="gmail_default">How about moving up the real_pid creator to the main process? does it work for you?</div><br></div><div><div class="gmail_default">static void verify_kill(unsigned int n)</div>{<br>        if (!real_pid) {<br>                real_pid = SAFE_FORK();<br>                if (!real_pid)<br>                        pause();<br>        }<br><br>        TEST(kill(*tc->pid, tc->test_sig));<br>        <span class="gmail_default">...</span><br><br>        if (real_pid) {<br>                cleanup();<br>                real_pid = 0;<br>        }<br><br></div><div class="gmail_default" style="font-size:small">}</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
For pid = 0, it means  then sig is sent to every process in the process <br>
group of the calling process.  So it looks like we test different thing <br>
when using -i parameters.  What do you think about this?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">I even think it is a good idea for code simplification:). In this case, the first</div></div><div class="gmail_default" style="font-size:small">the subtest is just to verify invalid signal for kill(), it doesn't matter to go with</div><div class="gmail_default" style="font-size:small">kill(0, invalid_signal), that only tries to kill the current main process. isn't it?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">If we go this way, not only the tc->child_flag is no needed, but also not necessary</div><div class="gmail_default" style="font-size:small">to fork a new child to be killed.</div><div><br></div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>