diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-06-13 13:59:00 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-06-13 13:59:00 -0300 |
commit | 5d09be48325cd17adff8b21dbff5a232bec89d84 (patch) | |
tree | f77226717713d68cb7ec6bb6012a31107b2e5211 /loslib.c | |
parent | 860e285f31ad388aa6d6ad38ff7d203d49378965 (diff) | |
download | lua-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.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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 | ||
226 | static int os_exit (lua_State *L) { | 226 | static 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 | |||
230 | static const luaL_Reg syslib[] = { | 234 | static const luaL_Reg syslib[] = { |
231 | {"clock", os_clock}, | 235 | {"clock", os_clock}, |
232 | {"date", os_date}, | 236 | {"date", os_date}, |