aboutsummaryrefslogtreecommitdiff
path: root/plugins/popen.c
diff options
context:
space:
mode:
authorGravatar Andreas Baumann <mail@andreasbaumann.cc> 2019-07-18 08:40:35 +0200
committerGravatar Andreas Baumann <mail@andreasbaumann.cc> 2019-07-18 08:40:35 +0200
commit34cc70c3c6428ba0d1f42994f5f0d6b4b8fc8711 (patch)
treec434bba834da4b42c85d00a2083c205307c8d55a /plugins/popen.c
parent2f4d6764d78cf085601b34ac92486405bd11095d (diff)
parente8325b39c47e6fbf7c8c1e31f9026870d9520af5 (diff)
downloadmonitoring-plugins-34cc70c3c6428ba0d1f42994f5f0d6b4b8fc8711.tar.gz
Merge branch 'master' into feature_check_curl
Diffstat (limited to 'plugins/popen.c')
-rw-r--r--plugins/popen.c52
1 files changed, 3 insertions, 49 deletions
diff --git a/plugins/popen.c b/plugins/popen.c
index 116d168d..557fb44e 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -78,14 +78,9 @@ RETSIGTYPE popen_timeout_alarm_handler (int);
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
-static void err_sys (const char *, ...) __attribute__((noreturn,format(printf, 1, 2)));
-char *rtrim (char *, const char *);
char *pname = NULL; /* caller can set this from argv[0] */
-/*int *childerr = NULL;*//* ptr to array allocated at run-time */
-/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
-
#ifdef REDHAT_SPOPEN_ERROR
static volatile int childtermd = 0;
#endif
@@ -184,6 +179,9 @@ spopen (const char *cmdstring)
}
argv[i] = NULL;
+ if(maxfd == 0)
+ maxfd = open_max();
+
if (childpid == NULL) { /* first time through */
if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL)
return (NULL);
@@ -296,47 +294,3 @@ popen_timeout_alarm_handler (int signo)
exit (STATE_CRITICAL);
}
}
-
-
-/* Fatal error related to a system call.
- * Print a message and die. */
-
-#define MAXLINE 2048
-static void
-err_sys (const char *fmt, ...)
-{
- int errnoflag = 1;
- int errno_save;
- char buf[MAXLINE];
-
- va_list ap;
-
- va_start (ap, fmt);
- /* err_doit (1, fmt, ap); */
- errno_save = errno; /* value caller might want printed */
- vsprintf (buf, fmt, ap);
- if (errnoflag)
- sprintf (buf + strlen (buf), ": %s", strerror (errno_save));
- strcat (buf, "\n");
- fflush (stdout); /* in case stdout and stderr are the same */
- fputs (buf, stderr);
- fflush (NULL); /* flushes all stdio output streams */
- va_end (ap);
- exit (1);
-}
-
-char *
-rtrim (char *str, const char *tok)
-{
- int i = 0;
- int j = sizeof (str);
-
- while (str != NULL && i < j) {
- if (*(str + i) == *tok) {
- sprintf (str + i, "%s", "\0");
- return str;
- }
- i++;
- }
- return str;
-}