This way, the typedef for size_t is executed only once.
2.3
If OPEN_MAX is indeterminite or ridiculously large (i.e., equal to LONG_MAX), we can use geTRlimit to get the per process maximum for open file descriptors. Since the per process limit can be modified, we can't cache the value obtained from the previous call (it might have changed). See Figure C.1.
Figure C.1. Alternate method for identifying the largest possible file descriptor
#include "apue.h" #include <limits.h> #include <sys/resource.h> #define OPEN_MAX_GUESS 256 long open_max(void) { long openmax; struct rlimit rl; if ((openmax = sysconf(_SC_OPEN_MAX)) < 0 || openmax == LONG_MAX) { if (getrlimit(RLIMIT_NOFILE, &rl) < 0) err_sys("can't get file limit"); if (rl.rlim_max == RLIM_INFINITY) openmax = OPEN_MAX_GUESS; else openmax = rl.rlim_max; } return(openmax); }