mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Support os.exit(status|true|false [,close]) (from Lua 5.2).
This commit is contained in:
parent
367ff0cdaa
commit
7338456796
11
src/lib_os.c
11
src/lib_os.c
@ -92,8 +92,15 @@ LJLIB_CF(os_getenv)
|
||||
|
||||
LJLIB_CF(os_exit)
|
||||
{
|
||||
exit(lj_lib_optint(L, 1, EXIT_SUCCESS));
|
||||
return 0; /* to avoid warnings */
|
||||
int status;
|
||||
if (L->base < L->top && tvisbool(L->base))
|
||||
status = boolV(L->base) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
else
|
||||
status = lj_lib_optint(L, 1, EXIT_SUCCESS);
|
||||
if (L->base+1 < L->top && tvistruecond(L->base+1))
|
||||
lua_close(L);
|
||||
exit(status);
|
||||
return 0; /* Unreachable. */
|
||||
}
|
||||
|
||||
LJLIB_CF(os_clock)
|
||||
|
Loading…
Reference in New Issue
Block a user