diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-09-23 08:33:06 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-09-23 08:33:06 (GMT) |
commit | 4295decfbf06adfa1bf019d28e9044971607b2d6 (patch) | |
tree | 416ac41722c554dab36231440b0f2846375a8b82 /plugins/runcmd.c | |
parent | bef0d0dd4ab04ac1189071526fae4031bec36b1d (diff) | |
download | monitoring-plugins-4295decfbf06adfa1bf019d28e9044971607b2d6.tar.gz |
open_max is a library function now, it should be mp_open_maxrefs/pull/1924/head
Diffstat (limited to 'plugins/runcmd.c')
-rw-r--r-- | plugins/runcmd.c | 8 |
1 files changed, 4 insertions, 4 deletions
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 */ |
89 | void np_runcmd_init(void) | 89 | void 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 | } |