[PATCH v8 4/5] Implement testing framework for pidns
Ákos Uzonyi
uzonyi.akos at gmail.com
Sun Aug 16 20:19:48 UTC 2020
On Sun, 16 Aug 2020 at 19:16, Dmitry V. Levin <ldv at altlinux.org> wrote:
> On Sun, Aug 16, 2020 at 07:08:48PM +0200, Ákos Uzonyi wrote:
> > On Sun, 16 Aug 2020 at 01:29, Ákos Uzonyi <uzonyi.akos at gmail.com> wrote:
> > > On Sat, 15 Aug 2020 at 22:27, Dmitry V. Levin <ldv at altlinux.org> wrote:
> > > > On Sun, Aug 09, 2020 at 04:13:05PM +0200, Ákos Uzonyi wrote:
> > [...]
> > > > > +static void
> > > > > +create_init_process(void)
> > > > > +{
> > > > > + int child_pipe[2];
> > > > > + if (pipe(child_pipe) < 0)
> > > > > + perror_msg_and_fail("pipe");
> > > > > +
> > > > > + pid_t pid = fork();
> > > > > + if (pid < 0)
> > > > > + perror_msg_and_fail("fork");
> > > > > +
> > > > > + if (!pid) {
> > > > > + close(child_pipe[1]);
> > > > > + _exit(read(child_pipe[0], &child_pipe[1], sizeof(int)) == 0);
> > > > > + }
> > > > > +
> > > > > + close(child_pipe[0]);
> > > > > +}
> > > >
> > > > If nothing is going to be written to child_pipe[1], then this read call is
> > > > expected to return 0, followed by _exit(1). The choice of exit code seems
> > > > strange to me.
> > >
> > > Oh yes, this is a mistake, I should have written "!=" instead of "==".
> > > I think I'll use an if, that's more readable.
> >
> > Actually, we do not really care about exit code, so I think I will
> > just use _exit(0), regardless of the return value of read.
>
> Ignoring the return value of read syscall might be tricky.
Oh, that's true. Then I'll go with the if version.
More information about the Strace-devel
mailing list