[LTP] [PATCH v2] close: add test for double close EBADF

Petr Vorel pvorel@suse.cz
Mon Apr 13 13:30:02 CEST 2026


Hi all,

...
> > +static void verify_close(unsigned int i)
> >  {
> > -       TST_EXP_FAIL(close(-1), EBADF);
> > +       int fd;
> > +       struct tcase *tc = &tcases[i];
> > +
> > +       switch (tc->type) {
> > +       case INVALID_FD:
> > +               TST_EXP_FAIL(close(-1), EBADF, "%s", tc->desc);
> > +               break;
> > +
> > +       case DOUBLE_CLOSE:
> > +               fd = SAFE_OPEN("close02", O_CREAT, 0600);

> According to the open(2) man page, the flags argument must include one
> of the access modes: O_RDONLY, O_WRONLY, or O_RDWR.

Good catch, Li.

> For example:

>   fd = SAFE_OPEN("close02", O_CREAT | O_RDWR, 0600);

> With the flag updated to include an access mode (like O_RDWR),
> it will look good to me:

> Reviewed-by: Li Wang <wangli.ahau@gmail.com>

Agree.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

And welcome back. Feel free to update .mailmap to the new address.

Kind regards,
Petr


More information about the ltp mailing list