summaryrefslogtreecommitdiffstats
path: root/gl/m4/getdtablesize.m4
diff options
context:
space:
mode:
authorKristian Schuster <116557017+KriSchu@users.noreply.github.com>2023-02-19 23:49:18 +0100
committerKristian Schuster <116557017+KriSchu@users.noreply.github.com>2023-02-19 23:49:18 +0100
commita0d42777217296c0a7bdb1e1be8d8f6de1b24dd7 (patch)
tree8effe94c57b2f9796ba36090b07551baa8f1e1cb /gl/m4/getdtablesize.m4
parentca3d59cd6918c9e2739e783b721d4c1122640fd3 (diff)
parentc07206f2ccc2356aa74bc6813a94c2190017d44e (diff)
downloadmonitoring-plugins-a0d4277.tar.gz
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option
Diffstat (limited to 'gl/m4/getdtablesize.m4')
-rw-r--r--gl/m4/getdtablesize.m463
1 files changed, 63 insertions, 0 deletions
diff --git a/gl/m4/getdtablesize.m4 b/gl/m4/getdtablesize.m4
new file mode 100644
index 00000000..8bcda905
--- /dev/null
+++ b/gl/m4/getdtablesize.m4
@@ -0,0 +1,63 @@
1# getdtablesize.m4 serial 8
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_GETDTABLESIZE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_FUNCS_ONCE([getdtablesize])
12 AC_CHECK_DECLS_ONCE([getdtablesize])
13 if test $ac_cv_func_getdtablesize = yes &&
14 test $ac_cv_have_decl_getdtablesize = yes; then
15 AC_CACHE_CHECK([whether getdtablesize works],
16 [gl_cv_func_getdtablesize_works],
17 [dnl There are two concepts: the "maximum possible file descriptor value + 1"
18 dnl and the "maximum number of open file descriptors in a process".
19 dnl Per SUSv2 and POSIX, getdtablesize() should return the first one.
20 dnl On most platforms, the first and the second concept are the same.
21 dnl On OpenVMS, however, they are different and getdtablesize() returns
22 dnl the second one; thus the test below fails. But we don't care
23 dnl because there's no good way to write a replacement getdtablesize().
24 case "$host_os" in
25 vms*) gl_cv_func_getdtablesize_works="no (limitation)" ;;
26 *)
27 dnl Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft
28 dnl limit up to an unchangeable hard limit; all other platforms
29 dnl correctly require setrlimit before getdtablesize() can report
30 dnl a larger value.
31 AC_RUN_IFELSE([
32 AC_LANG_PROGRAM(
33 [[#include <unistd.h>]
34 GL_MDA_DEFINES
35 ],
36 [[int size = getdtablesize();
37 if (dup2 (0, getdtablesize()) != -1)
38 return 1;
39 if (size != getdtablesize())
40 return 2;
41 ]])],
42 [gl_cv_func_getdtablesize_works=yes],
43 [gl_cv_func_getdtablesize_works=no],
44 [case "$host_os" in
45 cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
46 gl_cv_func_getdtablesize_works="guessing no" ;;
47 *) gl_cv_func_getdtablesize_works="guessing yes" ;;
48 esac
49 ])
50 ;;
51 esac
52 ])
53 case "$gl_cv_func_getdtablesize_works" in
54 *yes | "no (limitation)") ;;
55 *) REPLACE_GETDTABLESIZE=1 ;;
56 esac
57 else
58 HAVE_GETDTABLESIZE=0
59 fi
60])
61
62# Prerequisites of lib/getdtablesize.c.
63AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:])