[LTP] [PATCH v3 2/3] syscalls/pipe2_02: Add new test for pipe2 O_CLOEXEC flag

Li Wang liwang@redhat.com
Tue Apr 21 11:59:00 CEST 2020


Hi Xu,

Yang Xu <xuyang2018.jy@cn.fujitsu.com> wrote:

...
> >     +static void verify_pipe2(void)
> >     +{
> >     +       int pid, status;
> >     +       char buf[20];
> >     +
> >     +       SAFE_PIPE2(fds, O_CLOEXEC);
> >     +       sprintf(buf, "%d", fds[1]);
> >     +       pid = SAFE_FORK();
> >     +       if (pid == 0) {
> >     +               if (execlp(TESTBIN, TESTBIN, buf, NULL))
> >     +                       exit(2);
> >
> >
> > Do we really need the if() condition and exit(2)? AFAIK, the exec()
> > family of functions replaces the current process image with a new
> > process and returns zero if succeeded.
>   If failed, it will return -1. So we can catch 2(exit code) in the
> following code, but SAFE_EXECLP is also ok.
>

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.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200421/a05de910/attachment.htm>


More information about the ltp mailing list