From 5d09be48325cd17adff8b21dbff5a232bec89d84 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 13 Jun 2008 13:59:00 -0300 Subject: [PATCH] by default, 'os.exit' closes current state --- loslib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/loslib.c b/loslib.c index c1687226..643fa9c1 100644 --- a/loslib.c +++ b/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.22 2007/09/14 13:26:28 roberto Exp roberto $ +** $Id: loslib.c,v 1.23 2008/01/18 15:37:10 roberto Exp roberto $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -224,9 +224,13 @@ static int os_setlocale (lua_State *L) { static int os_exit (lua_State *L) { - exit(luaL_optint(L, 1, EXIT_SUCCESS)); + int status = luaL_optint(L, 1, EXIT_SUCCESS); + if (!lua_toboolean(L, 2)) + lua_close(L); + exit(status); } + static const luaL_Reg syslib[] = { {"clock", os_clock}, {"date", os_date},