aboutsummaryrefslogtreecommitdiff
path: root/src/reg.c
diff options
context:
space:
mode:
authorame <[email protected]>2024-05-12 21:00:33 -0500
committerame <[email protected]>2024-05-12 21:00:33 -0500
commit897f5843d61cc2d827b719e27d83d7f9cff3a20e (patch)
tree3454974aa1a4e408dd1f4ad2116788d21024c1e4 /src/reg.c
parent2b985e277f06a7086025ab292ddb22b5ded89189 (diff)
memopry stuff
Diffstat (limited to 'src/reg.c')
-rw-r--r--src/reg.c22
1 files changed, 10 insertions, 12 deletions
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 <lib>.array functions
lua_newtable(L);