From a84adf91992f19581e05ac617af7c259ec6b9d33 Mon Sep 17 00:00:00 2001 From: ame Date: Sun, 12 May 2024 21:00:33 -0500 Subject: memopry stuff --- src/reg.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/reg.c') diff --git a/src/reg.c b/src/reg.c index 966537f..417062a 100644 --- a/src/reg.c +++ b/src/reg.c @@ -18,22 +18,20 @@ void sigHandle(int s){ static int lua_exit(lua_State* L){ - sigHandle(0); + lib_thread_clean(); + //sigHandle(0); return 0; } int luaopen_llib(lua_State* L) { - lua_newuserdata(L, sizeof(void*)); - luaL_newmetatable(L, "gc"); - lua_pushstring(L, "__gc"); - lua_pushcfunction(L, &lua_exit); - lua_settable(L, -3); - - lua_setmetatable(L, -2); - lua_setfield(L, LUA_REGISTRYINDEX, "grr"); - signal(SIGTERM, sigHandle); - signal(SIGINT, sigHandle); - + lua_newuserdata(L, 1); + int ud = lua_gettop(L); + lua_newtable(L); + int meta = lua_gettop(L); + luaI_tsetcf(L, meta, "__gc", lua_exit); + lua_pushvalue(L, meta); + lua_setmetatable(L, ud); + //create .array functions lua_newtable(L); -- cgit v1.2.3