[LTP] close02: add test for double close EBADF
Andrea Cervesato
andrea.cervesato@suse.com
Wed May 13 09:07:57 CEST 2026
Hi Jinseok,
> Hi Jinseok,
>
> On 2026-05-13, Jinseok Kim wrote:
> > close02: add test for double close EBADF
>
> > +static void setup(void)
> > +{
> > + fd_closed = SAFE_OPEN("close02", O_CREAT | O_RDWR, 0600);
> > + if (close(fd_closed) == -1)
> > + tst_brk(TBROK | TERRNO, "close(%d) failed", fd_closed);
> > +}
>
> Use SAFE_CLOSE instead of a raw close(). Since SAFE_CLOSE sets the variable
> to -1, save the fd value first:
>
> int tmp_fd;
> fd_closed = SAFE_OPEN("close02", O_CREAT | O_RDWR, 0600);
> tmp_fd = fd_closed;
> SAFE_CLOSE(tmp_fd);
This is a corner case, please ignore.
Reagrds,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
More information about the ltp
mailing list