Given this code from  test-fdopendir.c, FreeBSD 8.1 fails

int
main (void)
{
  DIR *d;
  int fd;

  /* A non-directory cannot be turned into a directory stream.  */
  fd = open ("test-fdopendir.tmp", O_RDONLY | O_CREAT, 0600);
  ASSERT (0 <= fd);
  errno = 0;
  ASSERT (fdopendir (fd) == NULL);
  ASSERT (errno == ENOTDIR);
  ASSERT (close (fd) == 0);
  ...

because the close returns nonzero.
It sets errno to EBADF.

It's pretty obvious that this is a bug.

This is probably not relevant to coreutils,
(I don't think it can be made to call fdopendir on a non-dir FD)
so addressing it is not urgent.

Reply via email to