os.exit(0) is not processed properly #139
The statement “os.exit()” is not processed properly, both on Windows and Linux.
This simple code makes reproducable effect, both on Linux and Windows.
I also checked that the workspace directory is the directory where this script is located ( must not be important, but good to know ).
For comparison, another VSC Lua debugger
The text was updated successfully, but these errors were encountered:
The problem is not 0 or false, 1 or true. Its not the return value.
The problem with any workaround - avoiding to use os.exit() is, that all published standard code doesn´t use
but something like this
and I must modifiy this code to make it run in VSC. And as you see, its not just putting a comment "--" in front of the os.exit(result) statement,
Many Lua code is badly written, so there is not just one os.exit() statement, which are usually not idential but have different parameters ect.
So the next developer will argue, why did I modify the script so heavily at many code positions, just to separate the os.exit() from the real one and only "main" function call.
Vice versa, if I publish code into a code repository ( on GitHub..), if I publish my original code, I can´t follow the standard rules... if I use the last-tested code I run in VSC. I still must uncomment the os.exit(result) statement...
You even suggest me to use a different syntax, which is not standard with given Lua code.
So I would be pleased about a fix, so that standard code runs properly within VSC and your debugger.
Btw, whats the reason for the os.exit() problem ?
So there is just ONE parameter.
So a batch file ( the script running in a shell ) can react to the return codes.
As this is basic knowledge and common culture since 50 years ( since Unix & C started ), swapped to the PC with MSDOS ( and later Windows ), ATARI-ST GEM & COMMODORE-AMIGA OS shells, later to Linux on PC, everybody is using an exit() with no or one parameter.
I know exit() since about 1987, when I had first C experiences on MSDOS.
works fine both on Linux and Windows command line, with LUA script files.
There are the following os.exit() statements in the core files
** luaunit.lua **
** test_luaunit.lua **
this requires hard code modification, I am even confused, as the delicate function is transfered to another function.... and not the result
** run_unit_tests.lua **
so this last line is where I must modify the code, not just put a "--" in front of.
Especially, LUA is the first programming language, where "everywhere" the script is ended with an os.exit() at all, all other programming languages don´t require such explicte statement,
How do you cleanly exit interactive Lua?
Why and when im gonna use the parameter “code” of the os.exit() function in Lua
.. nobody mentions a mandatory second parameter.
How to end script execution gracefully?
Obviously, VSC requires that the Lua state is closed before exiting.
So you have to add the lua_close to avoid the crash. Standard LUA applications don´t use this 2nd. parameter.
How can the default friendly behaviour of an non-given optional parameter ( the value which is taken if the optional parameter is not used ), which was introduced "lately" ( Roblox Lua is 5.1, Core Lua is 5.3., many Lua frameworks and applications are started with LUA 5.0 or even earlier ), be irrelevant for the developer of a VSC debugger plugin ?
Please modify your VSC plugin, so that
Yes, standard is that Lua has ONE parameter for exit(), as with most other computer languages.
Most other known programming languages with shell application option for their applications offer an exit() too, I don´t know any other than LUA where a second parameter is implemented.
And as the OPTIONAL parameter of os.exit() is implemented recently, it can´t be that all given OpenSource Lua code must be modified....
As such the code is written since 20 years of Lua, and for any other programming language since 50 years.
The shells don´t crash if Lua is terminated this way,
VSC plugins don´t have to crash the applications they are debugging, if the application follow the standard rules.
It is one of 100s of Lua applications, which end by
Why do you make your VSC plugin worthless, as I must comment "you must modify given OpenSource code heavily to let it run in this debugger ?
Why do you insist - as VSC plugin developer - to urge developers of your target language Lua for certain irrelevant code rules ?
As the title is
its a complete new runtime?!
I even don´t see now a "fork",
, and if possible name references ( web articles...) about this.
And by keeping the Lua state open, though the debug session ends,
I would be pleased about an article by you,
For 99% of Lua applications: