Hello,

thanks for the new release of findutils in the first place!

While I was trying to build packages for Fedora, I ran into huge test-suite 
failure.  For merely all tests the assertion within complain_about_leaky_fds 
() failed on the descriptor 3 or 4.

Poking around, I discovered the function fd_is_cloexec () does not work
there.  As it seems to be kernel specific, I haven't been able to reproduce
it locally.

Here is a minimal example:

int main()
{
  const int fd = open(".", O_RDONLY|O_CLOEXEC);
  if (-1 == fd)
    return EXIT_FAILURE;

  const int flags = fcntl(fd, F_GETFD);
  printf("fcntl(%d, F_GETFD) = 0x%x\n", fd, flags);
  return EXIT_SUCCESS;
}

The call of fnctl () returns 0x0 on the buildhost.

I was able to get over the failure using the attached patch.

Kamil
diff --git a/lib/fdleak.c b/lib/fdleak.c
index 2c362cf..98e0caf 100644
--- a/lib/fdleak.c
+++ b/lib/fdleak.c
@@ -186,7 +186,7 @@ static int
 fd_is_cloexec (int fd)
 {
   const int flags = fcntl (fd, F_GETFD);
-  return flags & FD_CLOEXEC;
+  return (flags & FD_CLOEXEC) || (fcntl (fd, F_GETFL) & O_CLOEXEC);
 }
 
 

Reply via email to