about summary refs log tree commit diff
path: root/dirent/bug-readdir1.c
diff options
context:
space:
mode:
Diffstat (limited to 'dirent/bug-readdir1.c')
-rw-r--r--dirent/bug-readdir1.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/dirent/bug-readdir1.c b/dirent/bug-readdir1.c
index f9c609cc98..1f70722dd2 100644
--- a/dirent/bug-readdir1.c
+++ b/dirent/bug-readdir1.c
@@ -23,11 +23,12 @@ main (void)
       exit (1);
     }
 
-  /* close the dir stream, making it invalid */
-  if (closedir (dirp))
+  /* close the directory file descriptor, making it invalid */
+  if (close (dirfd (dirp)) != 0)
     {
-      perror ("closedir");
-      exit (1);
+      puts ("could not close directory file descriptor");
+      /* This is not an error.  It is not guaranteed this is possible.  */
+      return 0;
     }
 
   ent = readdir (dirp);