New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os.exit(0) is not processed properly #139
Comments
You can use |
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 ? |
I don't think os.exit(0) is a standard usage. The second parameter of os.exit determines whether to call lua_close. A lua program can only exit correctly when it finally calls lua_close. Exit without lua_close is no different from crash. |
a) 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. b)
works fine both on Linux and Windows command line, with LUA script files. c) http://www.github.com/bluebird75/luaunit 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, d) How do you cleanly exit interactive Lua? Why and when im gonna use the parameter “code” of the os.exit() function in Lua https://www.lua.org/pil/1.1.html
.. nobody mentions a mandatory second parameter. e) How to end script execution gracefully?
http://www.lua.org/manual/5.3/manual.html#pdf-os.exit
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 |
a) b) |
a)
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.... b) either nothing 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. c) It is one of 100s of Lua applications, which end by os.exit() 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 ? d) As the title is its a complete new runtime?! I even don´t see now a "fork", e) f) , 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: |
I don't want to engage in such meaningless arguments anymore. You can use the solution I provide you, or find a solution by yourself. |
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
http://marketplace.visualstudio.com/items?itemName=tomblind.local-lua-debugger-vscode
processes os.exit(0) always properly.
But I need your debugger, as the "Lua Test Adapter" depends on it...
The text was updated successfully, but these errors were encountered: