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