* lib/fts.c (fts_close): Detect close failure, not just fchdir failure,
and propagate to caller, along with errno.
2009-09-01 Jim Meyering <meyering@redhat.com>
+ fts: fts_close now fails also when closing a dir file descriptor fails
+ * lib/fts.c (fts_close): Detect close failure, not just fchdir failure,
+ and propagate to caller, along with errno.
+
announce-gen: correct formatting in --help output
* build-aux/announce-gen (usage): Move the one-line description in
--help output "up", to where it belongs, just after Usage:.
if (ISSET(FTS_CWDFD))
{
if (0 <= sp->fts_cwd_fd)
- close (sp->fts_cwd_fd);
+ if (close (sp->fts_cwd_fd))
+ saved_errno = errno;
}
else if (!ISSET(FTS_NOCHDIR))
{
/* Return to original directory, save errno if necessary. */
if (fchdir(sp->fts_rfd))
saved_errno = errno;
- close(sp->fts_rfd);
+
+ /* If close fails, record errno only if saved_errno is zero,
+ so that we report the probably-more-meaningful fchdir errno. */
+ if (close (sp->fts_rfd))
+ if (saved_errno == 0)
+ saved_errno = errno;
}
fd_ring_clear (&sp->fts_fd_ring);