commit 5d09be48325cd17adff8b21dbff5a232bec89d84
parent 860e285f31ad388aa6d6ad38ff7d203d49378965
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 13 Jun 2008 13:58:37 -0300
by default, 'os.exit' closes current state
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git 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},