diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-09-04 15:04:09 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-09-04 15:04:09 +0200 |
commit | c209ed36b6aaaa992df8976789c8ba8112f8e5c5 (patch) | |
tree | 750f886c59728842787e58441d39439819050c27 /tex/context/base/mkiv/util-lua.lua | |
parent | 1ee48eeafd4e46712a29c91ad704b882f00d765f (diff) | |
download | context-c209ed36b6aaaa992df8976789c8ba8112f8e5c5.tar.gz |
2016-09-04 13:51:00
Diffstat (limited to 'tex/context/base/mkiv/util-lua.lua')
-rw-r--r-- | tex/context/base/mkiv/util-lua.lua | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/tex/context/base/mkiv/util-lua.lua b/tex/context/base/mkiv/util-lua.lua index d4020a1e9..b3346006c 100644 --- a/tex/context/base/mkiv/util-lua.lua +++ b/tex/context/base/mkiv/util-lua.lua @@ -159,14 +159,20 @@ end -- -- print(luautilities.datatype(lpeg.P("oeps"))) --- local finalizers = { } --- --- function luautilities.registerfinalizer(f) --- finalizers[#finalizers+1] = f --- end --- --- function luautilities.finalize() --- for i=1,#finalizers do --- pcall(finalizers[i]) --- end --- end +-- 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 |