+Mon Nov 7 21:22:00 1994 Theodore Y. Ts'o (tytso@dcl)
+
+ * getdtablesize.c: Use POSIX method of obtaining fd table size,
+ if available.
+
Thu Oct 27 20:07:03 1994 Mark Eichin (eichin@cygnus.com)
* login.c (main): if CSTATUS is missing, don't set c_cc[VSTATUS]
-/* Placed in the Public Domain by Mark Eichin, Cygnus Support 1994 */
+#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;
+ struct rlimit rl;
+ getrlimit(RLIMIT_NOFILE, &rl);
+ return rl.rlim_cur;
}
+#endif