summaryrefslogtreecommitdiffstats
path: root/web/attachments/148122-waitpid.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/148122-waitpid.patch')
-rw-r--r--web/attachments/148122-waitpid.patch54
1 files changed, 54 insertions, 0 deletions
diff --git a/web/attachments/148122-waitpid.patch b/web/attachments/148122-waitpid.patch
new file mode 100644
index 0000000..dc6c06a
--- /dev/null
+++ b/web/attachments/148122-waitpid.patch
@@ -0,0 +1,54 @@
1--- nagios-plugins-1.4.1/plugins/popen.c.orig 2005-09-05 14:02:00.314775817 +0200
2+++ nagios-plugins-1.4.1/plugins/popen.c 2005-09-05 14:16:21.427287267 +0200
3@@ -30,6 +30,7 @@
4
5 FILE *spopen (const char *);
6 int spclose (FILE *);
7+static RETSIGTYPE popen_sigchld_handler (int);
8 RETSIGTYPE popen_timeout_alarm_handler (int);
9
10 #include <stdarg.h> /* ANSI C header file */
11@@ -66,6 +67,7 @@
12 /*int *childerr = NULL;*//* ptr to array allocated at run-time */
13 /*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
14 static int maxfd; /* from our open_max(), {Prog openmax} */
15+static volatile int childtermd = 0; /* set by SIGCHLD handler */
16
17 FILE *
18 spopen (const char *cmdstring)
19@@ -171,6 +173,10 @@
20 if (pipe (pfderr) < 0)
21 return (NULL); /* errno set by pipe() */
22
23+ if (signal (SIGCHLD, popen_sigchld_handler) == SIG_ERR) {
24+ usage4 (_("Cannot catch SIGCHLD"));
25+ }
26+
27 if ((pid = fork ()) < 0)
28 return (NULL); /* errno set by fork() */
29 else if (pid == 0) { /* child */
30@@ -220,6 +226,8 @@
31 if (fclose (fp) == EOF)
32 return (1);
33
34+ while (!childtermd); /* wait until SIGCHLD */
35+
36 while (waitpid (pid, &status, 0) < 0)
37 if (errno != EINTR)
38 return (1); /* error other than EINTR from waitpid() */
39@@ -239,8 +247,14 @@
40 #define OPEN_MAX_GUESS 256 /* if OPEN_MAX is indeterminate */
41 /* no guarantee this is adequate */
42
43+static RETSIGTYPE
44+popen_sigchld_handler (int signo)
45+{
46+ if (signo == SIGCHLD)
47+ childtermd = 1;
48+}
49
50-void
51+RETSIGTYPE
52 popen_timeout_alarm_handler (int signo)
53 {
54 int fh;