Only check /proc/$$/fd if we have the dirfd function/macro.

This commit is contained in:
Todd C. Miller
2004-06-01 20:51:56 +00:00
parent 54cb0921de
commit cebfa4c030

View File

@@ -59,6 +59,7 @@ closefrom(lowfd)
int lowfd;
{
long fd, maxfd;
#ifdef HAVE_DIRFD
char fdpath[PATH_MAX], *endp;
struct dirent *dent;
DIR *dirp;
@@ -73,8 +74,10 @@ closefrom(lowfd)
fd >= 0 && fd < INT_MAX && fd >= lowfd && fd != dirfd(dirp))
(void) close((int) fd);
}
closedir(dirp);
} else {
(void) closedir(dirp);
} else
#endif
{
/*
* Fall back on sysconf() or getdtablesize(). We avoid checking
* resource limits since it is possible to open a file descriptor