aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--io.c7
2 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index eb7555f2..f0c3dc4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-01-05 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * io.c (wait_any): If the `interesting' argument is non-zero, then we
+ must not return until that child process has exited, since the caller
+ gawk_pclose depends on our returning its exit status. So in that case,
+ do not pass WNOHANG to waitpid.
+
2015-01-04 Andrew J. Schorr <aschorr@telemetry-investments.com>
* gawkapi.h: Fix another comment typo.
diff --git a/io.c b/io.c
index 6e6d1a1a..f849f839 100644
--- a/io.c
+++ b/io.c
@@ -2250,7 +2250,12 @@ wait_any(int interesting) /* pid of interest, if any */
#endif
for (;;) {
# if defined(HAVE_WAITPID) && defined(WNOHANG)
- if ((pid = waitpid(-1, & status, WNOHANG)) == 0)
+ /*
+ * N.B. If the caller wants status for a specific child process
+ * (i.e. interesting is non-zero), then we must hang until we
+ * get exit status for that child.
+ */
+ if ((pid = waitpid(-1, & status, (interesting ? 0 : WNOHANG))) == 0)
/* No children have exited */
break;
# elif defined(HAVE_SYS_WAIT_H) /* POSIX compatible sys/wait.h */