summary refs log tree commit diff
path: root/src/libstddjb/dir_close.c
blob: 0af6f0e1b391f079d174914cc83033a6f67ef531 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* ISC license. */

#include <errno.h>
#include <skalibs/direntry.h>

int dir_close (DIR *dir)
{
  register unsigned int done = 0 ;
doit:
  done++ ;
  if (!closedir(dir)) return 0 ;
  if (errno == EINTR) goto doit ;
  return ((errno == EBADF) && (done > 1)) ? 0 : -1 ;
}