summaryrefslogtreecommitdiff
path: root/src/libstddjb/dir_close.c
blob: 1b7b16ac2f8fd390eba1650100597528d91aa833 (plain)
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)
{
  unsigned int done = 0 ;
doit:
  done++ ;
  if (!closedir(dir)) return 0 ;
  if (errno == EINTR) goto doit ;
  return ((errno == EBADF) && (done > 1)) ? 0 : -1 ;
}