summaryrefslogtreecommitdiff
path: root/src/libstddjb/dir_close.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/dir_close.c')
-rw-r--r--src/libstddjb/dir_close.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/libstddjb/dir_close.c b/src/libstddjb/dir_close.c
index 1b7b16a..4c5d0cf 100644
--- a/src/libstddjb/dir_close.c
+++ b/src/libstddjb/dir_close.c
@@ -3,12 +3,13 @@
#include <errno.h>
#include <skalibs/direntry.h>
-int dir_close (DIR *dir)
+void dir_close (DIR *dir)
{
- unsigned int done = 0 ;
-doit:
- done++ ;
- if (!closedir(dir)) return 0 ;
- if (errno == EINTR) goto doit ;
- return ((errno == EBADF) && (done > 1)) ? 0 : -1 ;
+ int e = errno ;
+ for (;;)
+ {
+ if (closedir(dir) == 0) break ;
+ if (errno != EINTR) break ;
+ }
+ errno = e ;
}