diff options
author | Sven Nierlein <sven@nierlein.de> | 2019-02-15 10:36:28 +0100 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2019-02-15 10:36:28 +0100 |
commit | 7cafb0e84550035fe671662c293122be975065ca (patch) | |
tree | 5d80a8e80854edc41a72da668a89485505d7e5dc /plugins/common.h | |
parent | 2962148d8bac3a65f1fb5e1a948e3f0a86a42a1a (diff) | |
download | monitoring-plugins-7cafb0e84550035fe671662c293122be975065ca.tar.gz |
check_by_ssh: fix child process leak on timeouts
When check_by_ssh runs into a timeout it simply exits keeping all child processes running.
Simply adopting the kill loop from runcmd_timeout_alarm_handler() fixes this.
Signed-off-by: Sven Nierlein <sven@nierlein.de>
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_ */ |