[Nagiosplug-checkins] nagiosplug/plugins popen.c,1.12,1.13
Ton Voon
tonvoon at users.sourceforge.net
Mon Sep 12 03:32:32 CEST 2005
- Previous message: [Nagiosplug-checkins] nagiosplug Makefile.am,1.27,1.28 configure.in,1.147,1.148
- Next message: [Nagiosplug-checkins] nagiosplug/config_test child_test.c,NONE,1.1 Makefile,NONE,1.1 run_tests,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23287/plugins
Modified Files:
popen.c
Log Message:
ECHILD error at waitpid on Red Hat systems (Peter Pramberger and
Sascha Runschke - 1250191)
Index: popen.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/popen.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- popen.c 1 May 2005 20:12:03 -0000 1.12
+++ popen.c 12 Sep 2005 10:31:28 -0000 1.13
@@ -30,6 +30,9 @@
FILE *spopen (const char *);
int spclose (FILE *);
+#ifdef REDHAT_SPOPEN_ERROR
+RETSIGTYPE popen_sigchld_handler (int);
+#endif
RETSIGTYPE popen_timeout_alarm_handler (int);
#include <stdarg.h> /* ANSI C header file */
@@ -67,6 +70,10 @@
/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
static int maxfd; /* from our open_max(), {Prog openmax} */
+#ifdef REDHAT_SPOPEN_ERROR
+static volatile int childtermd = 0;
+#endif
+
FILE *
spopen (const char *cmdstring)
{
@@ -171,6 +178,12 @@
if (pipe (pfderr) < 0)
return (NULL); /* errno set by pipe() */
+#ifdef REDHAT_SPOPEN_ERROR
+ if (signal (SIGCHLD, popen_sigchld_handler) == SIG_ERR) {
+ usage4 (_("Cannot catch SIGCHLD"));
+ }
+#endif
+
if ((pid = fork ()) < 0)
return (NULL); /* errno set by fork() */
else if (pid == 0) { /* child */
@@ -220,6 +233,10 @@
if (fclose (fp) == EOF)
return (1);
+#ifdef REDHAT_SPOPEN_ERROR
+ while (!childtermd); /* wait until SIGCHLD */
+#endif
+
while (waitpid (pid, &status, 0) < 0)
if (errno != EINTR)
return (1); /* error other than EINTR from waitpid() */
@@ -239,8 +256,16 @@
#define OPEN_MAX_GUESS 256 /* if OPEN_MAX is indeterminate */
/* no guarantee this is adequate */
+#ifdef REDHAT_SPOPEN_ERROR
+RETSIGTYPE
+popen_sigchld_handler (int signo)
+{
+ if (signo == SIGCHLD)
+ childtermd = 1;
+}
+#endif
-void
+RETSIGTYPE
popen_timeout_alarm_handler (int signo)
{
int fh;
- Previous message: [Nagiosplug-checkins] nagiosplug Makefile.am,1.27,1.28 configure.in,1.147,1.148
- Next message: [Nagiosplug-checkins] nagiosplug/config_test child_test.c,NONE,1.1 Makefile,NONE,1.1 run_tests,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Commits
mailing list