diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2017-02-04 13:50:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-04 13:50:34 +0100 |
commit | 42f669beab39df38d2f4955b651541272126a04e (patch) | |
tree | f68d918629725f9306698bf0641910d1f714714b /lualibs-util-lua.lua | |
parent | 144f6d16fd79bd0496b3ae379b69227e0d9bbfa9 (diff) | |
parent | 1b2f8c0355210dbfd34b10ed4ff7f0c90fda062d (diff) | |
download | lualibs-master.tar.gz |
v2.5
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 |