summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-09-23 08:33:06 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-09-23 08:33:06 (GMT)
commit4295decfbf06adfa1bf019d28e9044971607b2d6 (patch)
tree416ac41722c554dab36231440b0f2846375a8b82 /plugins
parentbef0d0dd4ab04ac1189071526fae4031bec36b1d (diff)
downloadmonitoring-plugins-4295decfbf06adfa1bf019d28e9044971607b2d6.tar.gz
open_max is a library function now, it should be mp_open_maxrefs/pull/1924/head
Diffstat (limited to 'plugins')
-rw-r--r--plugins/popen.c2
-rw-r--r--plugins/runcmd.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/plugins/popen.c b/plugins/popen.c
index 7703afc..b395f14 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -178,7 +178,7 @@ spopen (const char *cmdstring)
178 } 178 }
179 argv[i] = NULL; 179 argv[i] = NULL;
180 180
181 long maxfd = open_max(); 181 long maxfd = mp_open_max();
182 182
183 if (childpid == NULL) { /* first time through */ 183 if (childpid == NULL) { /* first time through */
184 if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL) 184 if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL)
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index 9816142..bc0a497 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -88,7 +88,7 @@ extern void die (int, const char *, ...)
88 * through this api and thus achieve async-safeness throughout the api */ 88 * through this api and thus achieve async-safeness throughout the api */
89void np_runcmd_init(void) 89void np_runcmd_init(void)
90{ 90{
91 long maxfd = open_max(); 91 long maxfd = mp_open_max();
92 if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t)); 92 if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t));
93} 93}
94 94
@@ -191,7 +191,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
191 /* close all descriptors in np_pids[] 191 /* close all descriptors in np_pids[]
192 * This is executed in a separate address space (pure child), 192 * This is executed in a separate address space (pure child),
193 * so we don't have to worry about async safety */ 193 * so we don't have to worry about async safety */
194 long maxfd = open_max(); 194 long maxfd = mp_open_max();
195 for (i = 0; i < maxfd; i++) 195 for (i = 0; i < maxfd; i++)
196 if(np_pids[i] > 0) 196 if(np_pids[i] > 0)
197 close (i); 197 close (i);
@@ -219,7 +219,7 @@ np_runcmd_close(int fd)
219 pid_t pid; 219 pid_t pid;
220 220
221 /* make sure this fd was opened by popen() */ 221 /* make sure this fd was opened by popen() */
222 long maxfd = open_max(); 222 long maxfd = mp_open_max();
223 if(fd < 0 || fd > maxfd || !np_pids || (pid = np_pids[fd]) == 0) 223 if(fd < 0 || fd > maxfd || !np_pids || (pid = np_pids[fd]) == 0)
224 return -1; 224 return -1;
225 225
@@ -243,7 +243,7 @@ runcmd_timeout_alarm_handler (int signo)
243 if (signo == SIGALRM) 243 if (signo == SIGALRM)
244 puts(_("CRITICAL - Plugin timed out while executing system call")); 244 puts(_("CRITICAL - Plugin timed out while executing system call"));
245 245
246 long maxfd = open_max(); 246 long maxfd = mp_open_max();
247 if(np_pids) for(i = 0; i < maxfd; i++) { 247 if(np_pids) for(i = 0; i < maxfd; i++) {
248 if(np_pids[i] != 0) kill(np_pids[i], SIGKILL); 248 if(np_pids[i] != 0) kill(np_pids[i], SIGKILL);
249 } 249 }