diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2019-04-04 13:09:15 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2019-04-04 13:09:15 +0200 |
commit | 2f4d6764d78cf085601b34ac92486405bd11095d (patch) | |
tree | 550601dc79e74fd4c184dc96a95687d1d1238b43 /plugins/common.h | |
parent | faea5899ba3264581bf75649e4b399d0b69bd125 (diff) | |
parent | 5f16ba81c4af1a05e67806ca989a1dd46248a5fd (diff) | |
download | monitoring-plugins-2f4d6764d78cf085601b34ac92486405bd11095d.tar.gz |
Merge branch 'master' into feature_check_curl
Diffstat (limited to 'plugins/common.h')
-rw-r--r-- | plugins/common.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/plugins/common.h b/plugins/common.h index 6bf4fca4..0f08e2f6 100644 --- a/plugins/common.h +++ b/plugins/common.h @@ -225,4 +225,18 @@ enum { # define __attribute__(x) /* do nothing */ #endif +/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX. + * If that fails and the macro isn't defined, we fall back to an educated + * guess. There's no guarantee that our guess is adequate and the program + * will die with SIGSEGV if it isn't and the upper boundary is breached. */ +#define DEFAULT_MAXFD 256 /* fallback value if no max open files value is set */ +#define MAXFD_LIMIT 8192 /* upper limit of open files */ +#ifdef _SC_OPEN_MAX +static long maxfd = 0; +#elif defined(OPEN_MAX) +# define maxfd OPEN_MAX +#else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */ +# define maxfd DEFAULT_MAXFD +#endif + #endif /* _COMMON_H_ */ |