blob: 1b59b387e8089f34b0af8de849f1958fd49a9ce6 (
plain) (
tree)
|
|
#include <sys/types.h>
#include <dirent.h>
#include "getdtablecount.h"
#ifdef __linux__
int
getdtablecount(void)
{
struct dirent *dp;
DIR *dir;
int n;
/* XXX: return something different? */
if (!(dir = opendir("/proc/self/fd")))
return 0;
n = 0;
while ((dp = readdir(dir)))
if (dp->d_name[0] >= '0' && dp->d_name[0] <= '9')
n++;
closedir(dir);
return n;
}
#else
#error getdtablecount(2) not supported
#endif
|