<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Xu,</div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">Yang Xu <<a href="mailto:xuyang2018.jy@cn.fujitsu.com">xuyang2018.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>
> +static void verify_pipe2(void)<br>
> +{<br>
> + int pid, status;<br>
> + char buf[20];<br>
> +<br>
> + SAFE_PIPE2(fds, O_CLOEXEC);<br>
> + sprintf(buf, "%d", fds[1]);<br>
> + pid = SAFE_FORK();<br>
> + if (pid == 0) {<br>
> + if (execlp(TESTBIN, TESTBIN, buf, NULL))<br>
> + exit(2);<br>
> <br>
> <br>
> Do we really need the if() condition and exit(2)? AFAIK, the exec() <br>
> family of functions replaces the current process image with a new <br>
> process and returns zero if succeeded.<br>
If failed, it will return -1. So we can catch 2(exit code) in the <br>
following code, but <span class="gmail_default" style="font-size:small"></span>SAFE_EXECLP is also ok.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Since we have do check the status of children via WIFEXITED(status), so even failed with -1, that also should be caught. Anyway, SAFE_EXECLP() should work for us.</div></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>