diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | io.c | 4 | ||||
-rw-r--r-- | pc/ChangeLog | 4 | ||||
-rw-r--r-- | pc/Makefile.tst | 8 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 10 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/close_status.awk | 20 | ||||
-rw-r--r-- | test/close_status.ok | 6 |
10 files changed, 72 insertions, 5 deletions
@@ -1,3 +1,13 @@ +2022-12-10 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * io.c (wait_any): When saving a saved exit status returned by + _cwait or waitpid or wait in struct redirect's status field, we + should actually save the valued returned by sanitize_exit_status + instead of the raw status. This fixes a bug whereby a saved status + for a previously exited process was being returned by gawk_pclose + without first being sanitized. Thanks to Jakub Martisko + <jamartis@redhat.com> for reporting the bug. + 2022-02-10 Arnold D. Robbins <arnold@skeeve.com> * builtin.c (sanitize_exit_status): Fix formatting. @@ -2599,7 +2599,7 @@ wait_any(int interesting) /* pid of interest, if any */ for (redp = red_head; redp != NULL; redp = redp->next) if (interesting == redp->pid) { redp->pid = -1; - redp->status = status; + redp->status = sanitize_exit_status(status); break; } } @@ -2629,7 +2629,7 @@ wait_any(int interesting) /* pid of interest, if any */ for (redp = red_head; redp != NULL; redp = redp->next) if (pid == redp->pid) { redp->pid = -1; - redp->status = status; + redp->status = sanitize_exit_status(status); break; } } diff --git a/pc/ChangeLog b/pc/ChangeLog index e75df278..c5043baf 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,7 @@ +2022-12-10 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.tst: Regenerated. + 2022-02-09 Arnold D. Robbins <arnold@skeeve.com> * Makefile.tst: Regenerated. diff --git a/pc/Makefile.tst b/pc/Makefile.tst index f25e887b..4b3fb0a5 100644 --- a/pc/Makefile.tst +++ b/pc/Makefile.tst @@ -147,7 +147,8 @@ BASIC_TESTS = \ aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 aryprm8 aryprm9 \ arysubnm aryunasgn asgext awkpath assignnumfield assignnumfield2 \ back89 backgsub badassign1 badbuild callparam childin clobber \ - closebad clsflnam compare compare2 concat1 concat2 concat3 concat4 \ + closebad close_status clsflnam compare compare2 concat1 concat2 \ + concat3 concat4 \ concat5 convfmt datanonl defref delargv delarpm2 delarprm delfunc \ dfacheck2 dfamb1 dfastress dynlj escapebrace eofsplit eofsrc1 \ exit2 exitval1 exitval2 exitval3 fcall_exit fcall_exit2 fldchg \ @@ -1430,6 +1431,11 @@ closebad: @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +close_status: + @echo $@ + @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + clsflnam: @echo $@ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/ChangeLog b/test/ChangeLog index c45b2f43..ddae26ea 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2022-02-10 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (EXTRA_DIST): close_status, new test. + * close_status.awk, close_status.ok: New files. + 2022-02-09 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (EXTRA_DIST): indirectbuiltin2, new test. diff --git a/test/Makefile.am b/test/Makefile.am index 424aaa82..96dd3027 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -189,6 +189,8 @@ EXTRA_DIST = \ clos1way6.ok \ closebad.awk \ closebad.ok \ + close_status.awk \ + close_status.ok \ clsflnam.awk \ clsflnam.in \ clsflnam.ok \ @@ -1402,7 +1404,8 @@ BASIC_TESTS = \ aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 aryprm8 aryprm9 \ arysubnm aryunasgn asgext awkpath assignnumfield assignnumfield2 \ back89 backgsub badassign1 badbuild callparam childin clobber \ - closebad clsflnam compare compare2 concat1 concat2 concat3 concat4 \ + closebad close_status clsflnam compare compare2 concat1 concat2 \ + concat3 concat4 \ concat5 convfmt datanonl defref delargv delarpm2 delarprm delfunc \ dfacheck2 dfamb1 dfastress dynlj escapebrace eofsplit eofsrc1 \ exit2 exitval1 exitval2 exitval3 fcall_exit fcall_exit2 fldchg \ diff --git a/test/Makefile.in b/test/Makefile.in index 82b60902..94699c32 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -455,6 +455,8 @@ EXTRA_DIST = \ clos1way6.ok \ closebad.awk \ closebad.ok \ + close_status.awk \ + close_status.ok \ clsflnam.awk \ clsflnam.in \ clsflnam.ok \ @@ -1668,7 +1670,8 @@ BASIC_TESTS = \ aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 aryprm8 aryprm9 \ arysubnm aryunasgn asgext awkpath assignnumfield assignnumfield2 \ back89 backgsub badassign1 badbuild callparam childin clobber \ - closebad clsflnam compare compare2 concat1 concat2 concat3 concat4 \ + closebad close_status clsflnam compare compare2 concat1 concat2 \ + concat3 concat4 \ concat5 convfmt datanonl defref delargv delarpm2 delarprm delfunc \ dfacheck2 dfamb1 dfastress dynlj escapebrace eofsplit eofsrc1 \ exit2 exitval1 exitval2 exitval3 fcall_exit fcall_exit2 fldchg \ @@ -3134,6 +3137,11 @@ closebad: @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +close_status: + @echo $@ + @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + clsflnam: @echo $@ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 4c4cfa62..26831128 100644 --- a/test/Maketests +++ b/test/Maketests @@ -185,6 +185,11 @@ closebad: @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +close_status: + @echo $@ + @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + clsflnam: @echo $@ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/close_status.awk b/test/close_status.awk new file mode 100644 index 00000000..12b48d63 --- /dev/null +++ b/test/close_status.awk @@ -0,0 +1,20 @@ +BEGIN { + exit9 = "echo red; exit 9" + while ((exit9 | getline x) > 0) + print x + printf "close(%s) returned %s\n", exit9, close(exit9) + + # run it again, but don't reap the exit status + while ((exit9 | getline x) > 0) + print x + + exit0 = "echo blue; exit 0" + while ((exit0 | getline x) > 0) + print x + # reap status out of order + printf "close(%s) returned %s\n", exit0, close(exit0) + + # check that we got the correct status from the previously + # exited process + printf "close(%s) returned %s\n", exit9, close(exit9) +} diff --git a/test/close_status.ok b/test/close_status.ok new file mode 100644 index 00000000..fbdebeb0 --- /dev/null +++ b/test/close_status.ok @@ -0,0 +1,6 @@ +red +close(echo red; exit 9) returned 9 +red +blue +close(echo blue; exit 0) returned 0 +close(echo red; exit 9) returned 9 |