This is mostly to document the bug.
If these old platforms were still common I suppose we should
change the readdir module to work around it. However, I’m not
sure it’s worth the hassle at this point.
* doc/posix-functions/readdir.texi, doc/posix-functions/readdir_r.texi:
Document the bug.
* lib/fts.c (fts_build):
* lib/savedir.c (streamsavedir):
Work around it.
+2025-01-13 Paul Eggert <eggert@cs.ucla.edu>
+
+ fts, savedir: avoid glibc 2.2 readdir ENOENT bug
+ This is mostly to document the bug.
+ If these old platforms were still common I suppose we should
+ change the readdir module to work around it. However, I’m not
+ sure it’s worth the hassle at this point.
+ * doc/posix-functions/readdir.texi, doc/posix-functions/readdir_r.texi:
+ Document the bug.
+ * lib/fts.c (fts_build):
+ * lib/savedir.c (streamsavedir):
+ Work around it.
+
2025-01-13 Bruno Haible <bruno@clisp.org>
stdlib-h: Define WCOREDUMP, as required by POSIX:2024.
misbehavior on standard systems and so Gnulib does not attempt to
cater to them any more. If you know of any problems caused by this,
please send a bug report.
+@item
+When reading a directory that has been removed,
+this function sets @code{errno} to @code{ENOENT}
+instead of leaving @code{errno} alone to indicate EOF:
+glibc 2.2.5.
@end itemize
@item
This function is missing on some platforms:
Minix 3.1.8, mingw, MSVC 14.
+@item
+When reading a directory that has been removed,
+this function sets @code{errno} to @code{ENOENT}
+instead of leaving @code{errno} alone to indicate EOF:
+glibc 2.2.5.
@end itemize
__set_errno (0);
struct dirent *dp = readdir(cur->fts_dirp);
if (dp == NULL) {
+ /* Some readdir()s do not absorb ENOENT (dir
+ deleted but open). This bug was fixed in
+ glibc 2.3 (2002). */
+#if ! (2 < __GLIBC__ + (3 <= __GLIBC_MINOR__))
+ if (errno == ENOENT)
+ errno = 0;
+#endif
if (errno) {
cur->fts_errno = errno;
/* If we've not read any items yet, treat
errno = 0;
dp = readdir (dirp);
if (! dp)
- break;
+ {
+ /* Some readdir()s do not absorb ENOENT (dir deleted but open).
+ This bug was fixed in glibc 2.3 (2002). */
+#if ! (2 < __GLIBC__ + (3 <= __GLIBC_MINOR__))
+ if (errno == ENOENT)
+ errno = 0;
+#endif
+ break;
+ }
/* Skip "", ".", and "..". "" is returned by at least one buggy
implementation: Solaris 2.4 readdir on NFS file systems. */