summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/maxfd.c2
-rw-r--r--lib/maxfd.h2
-rw-r--r--lib/utils_cmd.c8
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/maxfd.c b/lib/maxfd.c
index dcd4d3db..529b3568 100644
--- a/lib/maxfd.c
+++ b/lib/maxfd.c
@@ -1,7 +1,7 @@
1#include "./maxfd.h" 1#include "./maxfd.h"
2#include <errno.h> 2#include <errno.h>
3 3
4long open_max (void) { 4long mp_open_max (void) {
5 long maxfd = 0L; 5 long maxfd = 0L;
6 /* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX. 6 /* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
7 * If that fails and the macro isn't defined, we fall back to an educated 7 * If that fails and the macro isn't defined, we fall back to an educated
diff --git a/lib/maxfd.h b/lib/maxfd.h
index 0d734c5c..45218d0f 100644
--- a/lib/maxfd.h
+++ b/lib/maxfd.h
@@ -4,6 +4,6 @@
4#define DEFAULT_MAXFD 256 /* fallback value if no max open files value is set */ 4#define DEFAULT_MAXFD 256 /* fallback value if no max open files value is set */
5#define MAXFD_LIMIT 8192 /* upper limit of open files */ 5#define MAXFD_LIMIT 8192 /* upper limit of open files */
6 6
7long open_max (void); 7long mp_open_max (void);
8 8
9#endif // _MAXFD_ 9#endif // _MAXFD_
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 71da9d24..ef7053a5 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -89,7 +89,7 @@ extern void die (int, const char *, ...)
89void 89void
90cmd_init (void) 90cmd_init (void)
91{ 91{
92 long maxfd = open_max(); 92 long maxfd = mp_open_max();
93 93
94 /* if maxfd is unnaturally high, we force it to a lower value 94 /* if maxfd is unnaturally high, we force it to a lower value
95 * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause 95 * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause
@@ -145,7 +145,7 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
145 /* close all descriptors in _cmd_pids[] 145 /* close all descriptors in _cmd_pids[]
146 * This is executed in a separate address space (pure child), 146 * This is executed in a separate address space (pure child),
147 * so we don't have to worry about async safety */ 147 * so we don't have to worry about async safety */
148 long maxfd = open_max(); 148 long maxfd = mp_open_max();
149 for (i = 0; i < maxfd; i++) 149 for (i = 0; i < maxfd; i++)
150 if (_cmd_pids[i] > 0) 150 if (_cmd_pids[i] > 0)
151 close (i); 151 close (i);
@@ -172,7 +172,7 @@ _cmd_close (int fd)
172 pid_t pid; 172 pid_t pid;
173 173
174 /* make sure the provided fd was opened */ 174 /* make sure the provided fd was opened */
175 long maxfd = open_max(); 175 long maxfd = mp_open_max();
176 if (fd < 0 || fd > maxfd || !_cmd_pids || (pid = _cmd_pids[fd]) == 0) 176 if (fd < 0 || fd > maxfd || !_cmd_pids || (pid = _cmd_pids[fd]) == 0)
177 return -1; 177 return -1;
178 178
@@ -385,7 +385,7 @@ timeout_alarm_handler (int signo)
385 printf (_("%s - Plugin timed out after %d seconds\n"), 385 printf (_("%s - Plugin timed out after %d seconds\n"),
386 state_text(timeout_state), timeout_interval); 386 state_text(timeout_state), timeout_interval);
387 387
388 long maxfd = open_max(); 388 long maxfd = mp_open_max();
389 if(_cmd_pids) for(i = 0; i < maxfd; i++) { 389 if(_cmd_pids) for(i = 0; i < maxfd; i++) {
390 if(_cmd_pids[i] != 0) kill(_cmd_pids[i], SIGKILL); 390 if(_cmd_pids[i] != 0) kill(_cmd_pids[i], SIGKILL);
391 } 391 }