bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG]? Strange return values of close()


From: Andrew J. Schorr
Subject: Re: [BUG]? Strange return values of close()
Date: Thu, 10 Feb 2022 08:46:15 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

I'll work on it. Attached is a simpler and clearer reproducer that I'll
add as a test case.

-Andy

On Thu, Feb 10, 2022 at 01:31:48AM -0700, arnold@skeeve.com wrote:
> Jakub, thanks for the for the report.
> 
> Andy, that patch looks good, please push it to gawk-5.1-stable. You 
> may need to pull first. If you can add a test, that'd be great.
> 
> Eli Z., the code in wait_any supposedly gets the exit status properly
> for Win32; please review.
> 
> Thanks all!
> 
> Arnold
> 
> "Andrew J. Schorr" <aschorr@telemetry-investments.com> wrote:
> 
> > Hi,
> >
> > Thanks for the bug report. The problem is that the exit status of a 
> > previously
> > reaped process is not being handled properly. The attached patch seems to 
> > fix
> > the issue for me, but I'm not able to test the Mingw32 piece of it. We 
> > should
> > probably add a test case and check that it works on all platforms.
> >
> > Regards,
> > Andy
> >
> > On Wed, Feb 09, 2022 at 03:44:03PM +0100, Jakub Martisko wrote:
> > > Hello,
> > > 
> > > there seems to be some strange behaviour with the close (reproducer is
> > > attached in case the formatting gets messed). Is the RC echo=2304 expected
> > > or is this a bug? I've tested the same thing with the gawk-4.0.2 (i.e.
> > > before the change described in) and it returns 2304 in all four cases.
> > > 
> > > Thanks,
> > > Jakub
> > > 
> > > [1]:
> > > https://www.gnu.org/software/gawk/manual/html_node/Close-Files-And-Pipes.html#FOOT29
> > > 
> > > $ ls
> > > gwk_prog
> > > $ gawk -f ./gwk_prog
> > > RC Empty=9 #this is the expected value based on unzip's return values
> > > RC echo=9
> > > $ unzip -o ./test.zip 2>/dev/null; echo $?
> > > 9
> > > 
> > > $ touch ./test.zip
> > > 
> > > $ ls
> > > 
> > > gwk_prog  test.zip
> > > $ gawk -f ./gwk_prog
> > > RC Empty=9
> > > RC echo=2304 # this is 256*9 btw
> > > $ unzip -o ./test.zip 2>/dev/null; echo $?
> > > 
> > > Archive:  ./test.zip
> > > 9
> > > 
> > > $ cat gwk_prog
> > > #!/usr/bin/gawk -f
> > > 
> > > BEGIN{
> > > rc=0;
> > > 
> > > extract_file="unzip -o ./test.zip 2>/dev/null";
> > > 
> > > #Just an empty cycle - returns 9 as expected
> > > while (extract_file|getline){
> > > continue;
> > > }
> > > rc=close(extract_file);
> > > print "RC Empty="rc;
> > > 
> > > 
> > > #Non empty cycle - extract_file should return 9
> > > while (extract_file|getline){
> > > cmd="echo"
> > > cmd|getline
> > > close(cmd)
> > > }
> > > rc=close(extract_file);
> > > print "RC echo="rc;
> > > }
> >
> > > 
> > > #!/usr/bin/gawk -f
> > > 
> > > BEGIN{
> > > rc=0;
> > > 
> > > extract_file="unzip -o ./test.zip 2>/dev/null";
> > > 
> > > #Just an empty cycle - returns 9 as expected
> > > while (extract_file|getline){
> > > continue;
> > > }
> > > rc=close(extract_file);
> > > print "RC Empty="rc;
> > > 
> > > 
> > > #Non empty cycle - extract_file should return 9
> > > while (extract_file|getline){
> > >   cmd="echo"
> > >   cmd|getline
> > >   close(cmd)
> > > }
> > > rc=close(extract_file);
> > > print "RC echo="rc;
> > > 
> > > }
> 

-- 
Andrew Schorr                      e-mail: aschorr@telemetry-investments.com
Telemetry Investments, L.L.C.      phone:  917-305-1748
152 W 36th St, #402                fax:    212-425-5550
New York, NY 10018-8765

Attachment: gawk.close
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]