Re: fdopendir: Fix fd leak and test failure on native Windows

2023-05-14 Thread KO Myung-Hun
Hi/2. Bruno Haible wrote: > KO Myung-Hun wrote: >>> dirfd is specified at >>> https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirfd.html >>> Which says that if "The dirp argument does not refer to a valid directory >>> stream" >>> the function may fail with error EINVAL. It may alterna

Re: fdopendir: Fix fd leak and test failure on native Windows

2023-05-10 Thread Bruno Haible
KO Myung-Hun wrote: > > dirfd is specified at > > https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirfd.html > > Which says that if "The dirp argument does not refer to a valid directory > > stream" > > the function may fail with error EINVAL. It may alternatively simply crash > > ("the

Re: fdopendir: Fix fd leak and test failure on native Windows

2023-05-10 Thread KO Myung-Hun
Bruno Haible wrote: > KO Myung-Hun wrote: >>> @@ -78,11 +82,17 @@ _gl_unregister_dirp_fd (int fd) >>> int >>> dirfd (DIR *dir_p) >>> { >>> +#if GNULIB_defined_DIR >>> + int fd = dir_p->fd_to_close; >> >> dirfd() allows to take an invalid `dir_p' ? > > No; this must be a misunderstanding. >

Re: fdopendir: Fix fd leak and test failure on native Windows

2023-05-09 Thread Bruno Haible
KO Myung-Hun wrote: > > @@ -78,11 +82,17 @@ _gl_unregister_dirp_fd (int fd) > > int > > dirfd (DIR *dir_p) > > { > > +#if GNULIB_defined_DIR > > + int fd = dir_p->fd_to_close; > > dirfd() allows to take an invalid `dir_p' ? No; this must be a misunderstanding. dirfd is specified at https://p

Re: fdopendir: Fix fd leak and test failure on native Windows

2023-05-08 Thread KO Myung-Hun
Hi/2. Bruno Haible wrote: > On native Windows, I see a test failure: > > FAIL: test-fdopendir > > > ../../gltests/test-fdopendir.c:76: assertion 'dup2 (fd, fd) == -1' failed > FAIL test-fdopendir.exe (exit status: 3) > > The cause of the problem is that POSIX [1] says: >

fdopendir: Fix fd leak and test failure on native Windows

2023-04-26 Thread Bruno Haible
nlinepubs/9699919799/functions/fdopendir.html 2023-04-26 Bruno Haible fdopendir: Fix fd leak and test failure on native Windows. -- * lib/dirent-private.h: On mingw, define 'struct gl_directory' as a wrapper around the original DIR. On MSVC, add