[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: os.execute bug on Windows when the program returns -1
- From: Kubo Takehiro <kubo@...>
- Date: Sun, 6 May 2018 20:58:59 +0900
On Sun, May 6, 2018 at 3:44 PM, Haoqian He <email@example.com> wrote:
> I have found a bug in the API "os.execute" when it runs a program that
> returns -1 on Lua 5.3.4 on Windows (Windows 10Home 64Bit, Version 10.0.16229
> Build 16229)
I guess that this issue will be fixed by the following patch.
(The patch is for lua 5.3.x. Replace LUA_USE_WINDOWS with LUA_WIN for Lua 5.2.)
Well, I have not tested it...
> os.execute ([command])
> This function is equivalent to the ISO C function system. It passes command to be executed by an operating system shell. Its first result is true if > the command terminated successfully, or nil otherwise. After this first result the function returns a string plus a number, as follows:
> "exit": the command terminated normally; the following number is the exit status of the command.
> "signal": the command was terminated by a signal; the following number is the signal that terminated the command.
There is third case as far as I checked the lua source code.
text representation of errno: the system function itself fails; the
following number is the value of ISO C variable errno.
"No error" is the text representation of errno zero.
The patch checks errno in order not to go into the third case when the
executed command's exit code is -1.