diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2015-01-05 12:37:43 -0500 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2015-01-05 12:37:43 -0500 |
commit | 0d867aa42ea8c3487678dcceea484c10c88914cb (patch) | |
tree | aa4e0d5dbc795b253d3bfa280995fa9ec8a27009 | |
parent | a29f6a213fb18c199a4b1358327dc6d21f59eb64 (diff) | |
download | egawk-0d867aa42ea8c3487678dcceea484c10c88914cb.tar.gz egawk-0d867aa42ea8c3487678dcceea484c10c88914cb.tar.bz2 egawk-0d867aa42ea8c3487678dcceea484c10c88914cb.zip |
Fix bug in io.c:wait_any where we may not have waited for the requested child process exit status.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | io.c | 7 |
2 files changed, 13 insertions, 1 deletions
@@ -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. @@ -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 */ |