summaryrefslogtreecommitdiffstats
path: root/plugins/popen.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/popen.c')
-rw-r--r--plugins/popen.c29
1 files changed, 0 insertions, 29 deletions
diff --git a/plugins/popen.c b/plugins/popen.c
index 592263f..116d168 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -78,7 +78,6 @@ RETSIGTYPE popen_timeout_alarm_handler (int);
78 78
79#define min(a,b) ((a) < (b) ? (a) : (b)) 79#define min(a,b) ((a) < (b) ? (a) : (b))
80#define max(a,b) ((a) > (b) ? (a) : (b)) 80#define max(a,b) ((a) > (b) ? (a) : (b))
81int open_max (void); /* {Prog openmax} */
82static void err_sys (const char *, ...) __attribute__((noreturn,format(printf, 1, 2))); 81static void err_sys (const char *, ...) __attribute__((noreturn,format(printf, 1, 2)));
83char *rtrim (char *, const char *); 82char *rtrim (char *, const char *);
84 83
@@ -86,7 +85,6 @@ char *pname = NULL; /* caller can set this from argv[0] */
86 85
87/*int *childerr = NULL;*//* ptr to array allocated at run-time */ 86/*int *childerr = NULL;*//* ptr to array allocated at run-time */
88/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */ 87/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
89static int maxfd; /* from our open_max(), {Prog openmax} */
90 88
91#ifdef REDHAT_SPOPEN_ERROR 89#ifdef REDHAT_SPOPEN_ERROR
92static volatile int childtermd = 0; 90static volatile int childtermd = 0;
@@ -187,13 +185,11 @@ spopen (const char *cmdstring)
187 argv[i] = NULL; 185 argv[i] = NULL;
188 186
189 if (childpid == NULL) { /* first time through */ 187 if (childpid == NULL) { /* first time through */
190 maxfd = open_max (); /* allocate zeroed out array for child pids */
191 if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL) 188 if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL)
192 return (NULL); 189 return (NULL);
193 } 190 }
194 191
195 if (child_stderr_array == NULL) { /* first time through */ 192 if (child_stderr_array == NULL) { /* first time through */
196 maxfd = open_max (); /* allocate zeroed out array for child pids */
197 if ((child_stderr_array = calloc ((size_t)maxfd, sizeof (int))) == NULL) 193 if ((child_stderr_array = calloc ((size_t)maxfd, sizeof (int))) == NULL)
198 return (NULL); 194 return (NULL);
199 } 195 }
@@ -273,15 +269,6 @@ spclose (FILE * fp)
273 return (1); 269 return (1);
274} 270}
275 271
276#ifdef OPEN_MAX
277static int openmax = OPEN_MAX;
278#else
279static int openmax = 0;
280#endif
281
282#define OPEN_MAX_GUESS 256 /* if OPEN_MAX is indeterminate */
283 /* no guarantee this is adequate */
284
285#ifdef REDHAT_SPOPEN_ERROR 272#ifdef REDHAT_SPOPEN_ERROR
286RETSIGTYPE 273RETSIGTYPE
287popen_sigchld_handler (int signo) 274popen_sigchld_handler (int signo)
@@ -311,22 +298,6 @@ popen_timeout_alarm_handler (int signo)
311} 298}
312 299
313 300
314int
315open_max (void)
316{
317 if (openmax == 0) { /* first time through */
318 errno = 0;
319 if ((openmax = sysconf (_SC_OPEN_MAX)) < 0) {
320 if (errno == 0)
321 openmax = OPEN_MAX_GUESS; /* it's indeterminate */
322 else
323 err_sys (_("sysconf error for _SC_OPEN_MAX"));
324 }
325 }
326 return (openmax);
327}
328
329
330/* Fatal error related to a system call. 301/* Fatal error related to a system call.
331 * Print a message and die. */ 302 * Print a message and die. */
332 303