diff options
author | Wynn Wolf Arbor | 2020-05-24 13:55:36 +0200 |
---|---|---|
committer | Wynn Wolf Arbor | 2020-05-24 14:05:54 +0200 |
commit | 687f61eb77d0878d752266ace8bb8933cf5f9556 (patch) | |
tree | cfa2c1f2cebce57cc8d212919cf3627dcad02284 /getdtablecount.c | |
parent | 420f9ad56e80e0dbd024eefd61eeafed4265742d (diff) | |
download | slowcgi-687f61eb77d0878d752266ace8bb8933cf5f9556.tar.gz |
Add getdtablecount(2)
This was taken from https://github.com/Duncaen/lobase
Diffstat (limited to '')
-rw-r--r-- | getdtablecount.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/getdtablecount.c b/getdtablecount.c new file mode 100644 index 0000000..5bfa5ed --- /dev/null +++ b/getdtablecount.c @@ -0,0 +1,26 @@ +#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))) + n++; + + closedir(dir); + return n; +} +#else +#error getdtablecount(2) not supported +#endif |