summaryrefslogtreecommitdiffstats
path: root/src/appl/bsd/getdtablesize.c
blob: 244616cc99f9ec857a73ba1b26c760c8d0dc2e3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <limits.h>

#ifdef _SC_OPEN_MAX
int getdtablesize() {
    return sysconf(_SC_OPEN_MAX);
}
#else
#include <sys/resource.h>
/* Placed in the Public Domain by Mark Eichin, Cygnus Support 1994 */

int getdtablesize() {
    struct rlimit rl;
    getrlimit(RLIMIT_NOFILE, &rl);
    return rl.rlim_cur;
}
#endif