/* * getdtablesize -- * * Several possibilites here. Note that while one * can emulate getdtablesize with getrlimit on SVR4 * or 4.3BSD (or later), these systems should be * POSIX.1 compliant, so sysconf is preferred. * */ #ifdef _SC_OPEN_MAX /* POSIX -- preferred */ if ((tableSize = sysconf(_SC_OPEN_MAX)) == -1) { perror("sysconf"); ... } #elif RLIMIT_NOFILE /* who is non POSIX but has this? */ if (getrlimit(RLIMIT_NOFILE, &rlimit) == -1) { perror("getrlimit"); exit(1); } tableSize = rlimit.rlim_max; #else /* assume old BSD type */ tableSize = getdtablesize(); #endif