aboutsummaryrefslogtreecommitdiff
path: root/lib/utils_cmd.h
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <sven@nierlein.de> 2019-02-15 10:36:28 +0100
committerGravatar Sven Nierlein <sven@nierlein.de> 2019-02-15 10:36:28 +0100
commit7cafb0e84550035fe671662c293122be975065ca (patch)
tree5d80a8e80854edc41a72da668a89485505d7e5dc /lib/utils_cmd.h
parent2962148d8bac3a65f1fb5e1a948e3f0a86a42a1a (diff)
downloadmonitoring-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 'lib/utils_cmd.h')
-rw-r--r--lib/utils_cmd.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h
index ebaf15be..6f3aeb81 100644
--- a/lib/utils_cmd.h
+++ b/lib/utils_cmd.h
@@ -32,4 +32,17 @@ void cmd_init (void);
#define CMD_NO_ARRAYS 0x01 /* don't populate arrays at all */
#define CMD_NO_ASSOC 0x02 /* output.line won't point to buf */
+/* This variable must be global, since there's no way the caller
+ * can forcibly slay a dead or ungainly running program otherwise.
+ * Multithreading apps and plugins can initialize it (via CMD_INIT)
+ * in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
+ * for the first time.
+ *
+ * The check for initialized values is atomic and can
+ * occur in any number of threads simultaneously. */
+static pid_t *_cmd_pids = NULL;
+
+RETSIGTYPE timeout_alarm_handler (int);
+
+
#endif /* _UTILS_CMD_ */