bug-gnu-utils
[Top][All Lists]
Advanced

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

RE: gawk bug when calling system()


From: Aharon Robbins
Subject: RE: gawk bug when calling system()
Date: Tue, 22 Jul 2008 09:36:08 -0400

Hi. This is cc'ed to the bug list so that perhaps someone else can find
the problem. (And bcc'ed to the gawk Windows maintainer.)

The issue is that under Windows, current gawk

        gawk 'BEGIN { print system("exit 11") }'

doesn't print the correct exit status.

I just checked, and the code for gawk's system() function in
builtin.c:do_system has not changed since 3.1.3.

Can someone with Windows experience / knowledge please look into
this for me?

Thanks,

Arnold

> Date: Mon, 21 Jul 2008 10:20:02 +0200
> From: address@hidden
> Subject: RE: gawk bug when calling system()
> To: address@hidden
>
> > I don't remember the threaad, but I am fairly certain that this is an
> > old issue and that it boiled down to the way window's system() returns
> > (or rather, doesn't return) the exit status of the program it runs.
>
> I think this is not a Windows problem. I don't have at the moment
> a C compiler available, but here is some evidence why it should
> work:
>
> (1) Some earlier gawk versions *do* return the correct exit status
> from system() (notably 3.1.3-2; reportedly also 3.1.4)
>
> (2) Some awk implementations under windows (for instance
> nawk in gnuwin32) do at least recognize if the exit status
> of the program called via system() is non-zero, though
> it is incorrectly returned as a floating point number
>
> (3) When I call a command with cmd /c PROGRAM, cmd returns the
> exit status of the program, for example:
>
> c:\> cmd /c gawk "BEGIN{exit 11}"
> c:\> echo %errorlevel%
> 11 
>
> (Admittedly this is a pretty weak evidence, because it only
> shows that cmd.exe does pass back the exit code, but it still
> could mean that system() would not do.
>
> (4) Languages like Perl and Ruby offer a system() call which
> executes a CMD /c "Program"..., and returns the exit status
> of "Program" correctly. Here too, we can not conclude (without
> looking at the code) whether they use the C function system(),
> but at least they show that it is possible to get the correct
> exit code under Windows.
>
> From my own experience in C++ long time ago (Windows 3.1), I
> remember that I could get the exit code of the called program
> with system in a similar way as from Unix (by shifting the
> result 8 bit). I have learned that later Windows versions
> support negative exit codes, and that exit codes can be 16 bit,
> so I don't know how these things work nowadays.
>
> > If you can show me otherwise, based on a pure C example, then 
> > I'd be happy
> > to take a closer look at the gawk code.
>
> I'm sadly not experienced in Windows programming (coming from
> the Unix side), but I think if you just compare the the code
> of gawk 3.1.3-2 and 3.1.6, you should find out why it works
> in the former, but not in the latter.
>
> Ronald




reply via email to

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