summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/popen.c b/plugins/popen.c
index 062cf27..f681069 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -30,6 +30,9 @@ extern FILE *child_process;
30 30
31FILE *spopen (const char *); 31FILE *spopen (const char *);
32int spclose (FILE *); 32int spclose (FILE *);
33#ifdef REDHAT_SPOPEN_ERROR
34RETSIGTYPE popen_sigchld_handler (int);
35#endif
33RETSIGTYPE popen_timeout_alarm_handler (int); 36RETSIGTYPE popen_timeout_alarm_handler (int);
34 37
35#include <stdarg.h> /* ANSI C header file */ 38#include <stdarg.h> /* ANSI C header file */
@@ -67,6 +70,10 @@ char *pname = NULL; /* caller can set this from argv[0] */
67/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */ 70/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
68static int maxfd; /* from our open_max(), {Prog openmax} */ 71static int maxfd; /* from our open_max(), {Prog openmax} */
69 72
73#ifdef REDHAT_SPOPEN_ERROR
74static volatile int childtermd = 0;
75#endif
76
70FILE * 77FILE *
71spopen (const char *cmdstring) 78spopen (const char *cmdstring)
72{ 79{
@@ -171,6 +178,12 @@ spopen (const char *cmdstring)
171 if (pipe (pfderr) < 0) 178 if (pipe (pfderr) < 0)
172 return (NULL); /* errno set by pipe() */ 179 return (NULL); /* errno set by pipe() */
173 180
181#ifdef REDHAT_SPOPEN_ERROR
182 if (signal (SIGCHLD, popen_sigchld_handler) == SIG_ERR) {
183 usage4 (_("Cannot catch SIGCHLD"));
184 }
185#endif
186
174 if ((pid = fork ()) < 0) 187 if ((pid = fork ()) < 0)
175 return (NULL); /* errno set by fork() */ 188 return (NULL); /* errno set by fork() */
176 else if (pid == 0) { /* child */ 189 else if (pid == 0) { /* child */
@@ -220,6 +233,10 @@ spclose (FILE * fp)
220 if (fclose (fp) == EOF) 233 if (fclose (fp) == EOF)
221 return (1); 234 return (1);
222 235
236#ifdef REDHAT_SPOPEN_ERROR
237 while (!childtermd); /* wait until SIGCHLD */
238#endif
239
223 while (waitpid (pid, &status, 0) < 0) 240 while (waitpid (pid, &status, 0) < 0)
224 if (errno != EINTR) 241 if (errno != EINTR)
225 return (1); /* error other than EINTR from waitpid() */ 242 return (1); /* error other than EINTR from waitpid() */
@@ -239,8 +256,16 @@ static int openmax = 0;
239#define OPEN_MAX_GUESS 256 /* if OPEN_MAX is indeterminate */ 256#define OPEN_MAX_GUESS 256 /* if OPEN_MAX is indeterminate */
240 /* no guarantee this is adequate */ 257 /* no guarantee this is adequate */
241 258
259#ifdef REDHAT_SPOPEN_ERROR
260RETSIGTYPE
261popen_sigchld_handler (int signo)
262{
263 if (signo == SIGCHLD)
264 childtermd = 1;
265}
266#endif
242 267
243void 268RETSIGTYPE
244popen_timeout_alarm_handler (int signo) 269popen_timeout_alarm_handler (int signo)
245{ 270{
246 int fh; 271 int fh;