<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Feiyu Zhu <<a href="mailto:zhufy.jy@cn.fujitsu.com">zhufy.jy@cn.fujitsu.com</a>> wrote:<br></div><div dir="ltr" class="gmail_attr"><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>
+       pid_t pid, child_pid[5];<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">I'd suggest dropping these two variables since it makes no sense to</div><div class="gmail_default" style="font-size:small">save the children PIDs in the following testing.</div><br></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">
+       int nsig, i, status;<br>
+<br>
+       pid = SAFE_FORK();<br>
+       if (pid == 0) {<br>
+               setpgrp();<br>
+               for (i = 0; i < 5; i++) {<br>
+                       child_pid[i] = SAFE_FORK();<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">if we drop the arrays, that loop would be like:</div><div class="gmail_default" style="font-size:small"><br></div>                for (i = 0; i < 5; i++) {<br>                        if (!SAFE_FORK())<br>                                pause();<br>                }<br><div class="gmail_default" style="font-size:small"></div><br></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">
+                       if (!child_pid[i])<br>
+                               pause();<br>
                }<br>
<br>
-               /*<br>
-                * Check to see if the process was terminated with the<br>
-                * expected signal.<br>
-                */<br>
-               nsig = WTERMSIG(status);<br>
-               if (!nsig) {<br>
-                       tst_resm(TFAIL, "Did not receive any signal");<br>
-               } else if (nsig == TEST_SIG) {<br>
-                       tst_resm(TPASS, "received expected signal %d",<br>
-                                nsig);<br>
-               } else {<br>
-                       tst_resm(TFAIL,<br>
-                                "expected signal %d received %d",<br>
-                                TEST_SIG, nsig);<br>
-               }<br>
+               TEST(kill(-getpgrp(), SIGKILL));<br>
+               if (TST_RET != 0)<br>
+                       tst_res(TFAIL | TTERRNO, "kill failed");<br>
+               tst_res(TINFO, "%d never received a signal", getpid());<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">This TINFO is a misleading message to people. If the process receives a signal</div><div class="gmail_default" style="font-size:small">but not been killed, how do you say that never received a signal? </div><div class="gmail_default" style="font-size:small">So I suggest deleting this line.<br></div><div class="gmail_default" style="font-size:small"> <br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+               exit(0);<br>
        }<br>
-<br>
-       cleanup();<br>
-       tst_exit();<br>
-}<br>
-<br>
-/*<br>
- * do_child()<br>
- */<br>
-void do_child(void)<br>
-{<br>
-       int exno = 1;<br>
-<br>
-       sleep(299);<br>
-<br>
-       tst_resm(TINFO, "%d never received a" " signal", getpid());<br>
-       exit(exno);<br>
-}<br>
-<br>
-/*<br>
- * setup() - performs all ONE TIME setup for this test<br>
- */<br>
-void setup(void)<br>
-{<br>
-       /* Setup default signal handling */<br>
-       tst_sig(FORK, DEF_HANDLER, cleanup);<br>
-<br>
-       TEST_PAUSE;<br>
+<br>
+       SAFE_WAITPID(pid, &status, 0);<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">What about waiting for any child process here?</div><div class="gmail_default" style="font-size:small">  SAFE_WAITPID(-1, &status, 0);</div><br></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">
+       nsig = WTERMSIG(status);<br>
+       if (nsig != SIGKILL) {<br>
+               tst_res(TFAIL, "wait: unexpected signal %d returned, "<br>
+                       "expected SIGKILL(9)", nsig);<br>
+               return;<br>
+       }<br>
+       tst_res(TPASS, "receive expected signal SIGKILL(9)");<br>
 }<br></blockquote><div><br></div><div> </div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>