Update.
[glibc.git] / dirent / bug-readdir1.c
blobf9c609cc984612bf954204af4e2096500455e944
1 #include <dirent.h>
2 #include <errno.h>
3 #include <errno.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <sys/types.h>
9 int
10 main (void)
12 DIR *dirp;
13 struct dirent* ent;
15 /* open a dir stream */
16 dirp = opendir ("/tmp");
17 if (dirp == NULL)
19 if (errno == ENOENT)
20 exit (0);
22 perror ("opendir");
23 exit (1);
26 /* close the dir stream, making it invalid */
27 if (closedir (dirp))
29 perror ("closedir");
30 exit (1);
33 ent = readdir (dirp);
35 return ent != NULL || errno != EBADF;