aboutsummaryrefslogtreecommitdiff
path: root/loslib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-06-13 13:59:00 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-06-13 13:59:00 -0300
commit5d09be48325cd17adff8b21dbff5a232bec89d84 (patch)
treef77226717713d68cb7ec6bb6012a31107b2e5211 /loslib.c
parent860e285f31ad388aa6d6ad38ff7d203d49378965 (diff)
downloadlua-5d09be48325cd17adff8b21dbff5a232bec89d84.tar.gz
lua-5d09be48325cd17adff8b21dbff5a232bec89d84.tar.bz2
lua-5d09be48325cd17adff8b21dbff5a232bec89d84.zip
by default, 'os.exit' closes current state
Diffstat (limited to 'loslib.c')
-rw-r--r--loslib.c8
1 files 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 @@
1/* 1/*
2** $Id: loslib.c,v 1.22 2007/09/14 13:26:28 roberto Exp roberto $ 2** $Id: loslib.c,v 1.23 2008/01/18 15:37:10 roberto Exp roberto $
3** Standard Operating System library 3** Standard Operating System library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -224,9 +224,13 @@ static int os_setlocale (lua_State *L) {
224 224
225 225
226static int os_exit (lua_State *L) { 226static int os_exit (lua_State *L) {
227 exit(luaL_optint(L, 1, EXIT_SUCCESS)); 227 int status = luaL_optint(L, 1, EXIT_SUCCESS);
228 if (!lua_toboolean(L, 2))
229 lua_close(L);
230 exit(status);
228} 231}
229 232
233
230static const luaL_Reg syslib[] = { 234static const luaL_Reg syslib[] = {
231 {"clock", os_clock}, 235 {"clock", os_clock},
232 {"date", os_date}, 236 {"date", os_date},