On Thu, Sep 15, 2022 at 10:19 PM Cyril Hrubis <chrubis@suse.cz> wrote:
Hi!
> > diff --git a/testcases/kernel/syscalls/open/open04.c b/testcases/kernel/syscalls/open/open04.c
> > index d452405d4..01a8b12d6 100644
> > --- a/testcases/kernel/syscalls/open/open04.c
> > +++ b/testcases/kernel/syscalls/open/open04.c
> > @@ -33,7 +33,12 @@ static void setup(void)
>
> >     for (i = first + 1; i < fds_limit; i++) {
> >             sprintf(fname, FNAME ".%d", i);
> > -           fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0777);
> > +           fd = open(fname, O_RDWR | O_CREAT, 0777);
> > +           if (fd == -1) {
> > +                   if (errno != EMFILE)
> > +                           tst_brk(TBROK, "Expected EMFILE but got %d", errno);
> > +                   break;
> > +           }
> >             fds[i - first] = fd;
> >     }
> >  }
>
> LGTM.
> Reviewed-by: Petr Vorel <pvorel@suse.cz>

I faintly remmeber a similar patch where we decided not to work around
for a test harness leaking filedescriptors into testcases.

This also should be a solution, I searched the mailing list and got a patch[1].
Do you mean adding that close-on-exec flag when opening fd in harness?


--
Regards,
Li Wang