[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [PATCH] Lua Leak in OS Library. os.atexit()?
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Sun, 6 Sep 2009 18:16:00 -0700
Fixed a bug. The os.atexit() functions where being called after a full GC.
--
Robert G. Jakabosky
local exit_list={}
local exit=os.exit
local function cleanup()
-- call atexit functions in reverse order
for x=#exit_list,1,-1 do
local func = exit_list[x]
func()
exit_list[x] = nil
end
end
-- catch normal exit.
local gc=newproxy(true)
exit_list.gc = gc
gc=getmetatable(gc)
gc.__gc = cleanup
os.exit = function(...)
cleanup()
exit(...)
end
os.atexit = function(func)
table.insert(exit_list, func)
end