diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2016-09-15 08:07:32 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2016-09-15 08:07:32 +0200 |
commit | 349d46eb1e7f1d13f5d823e818216b5ef1cee566 (patch) | |
tree | 6c721f136781389e80392c4e5d3c714bb089afb8 /lualibs-util-lua.lua | |
parent | 8ee68eedb5cbdf06585f6f37bdc361b69437a25d (diff) | |
download | lualibs-349d46eb1e7f1d13f5d823e818216b5ef1cee566.tar.gz |
sync with Context as of 2016-09-15
Diffstat (limited to 'lualibs-util-lua.lua')
-rw-r--r-- | lualibs-util-lua.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lualibs-util-lua.lua b/lualibs-util-lua.lua index e1dcdc9..b334600 100644 --- a/lualibs-util-lua.lua +++ b/lualibs-util-lua.lua @@ -158,3 +158,21 @@ end -- luautilities.registerdatatype(lpeg.P("!"),"lpeg") -- -- print(luautilities.datatype(lpeg.P("oeps"))) + +-- These finalizers will only be invoked when we have a proper lua_close +-- call (which is not happening in luatex tex node yes) or finish with an +-- os.exit(n,true). + +local finalizers = { } + +setmetatable(finalizers, { + __gc = function(t) + for i=1,#t do + pcall(t[i]) -- let's not crash + end + end +} ) + +function luautilities.registerfinalizer(f) + finalizers[#finalizers+1] = f +end |