aboutsummaryrefslogtreecommitdiff
path: root/system/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'system/init.lua')
-rw-r--r--system/init.lua16
1 files changed, 3 insertions, 13 deletions
diff --git a/system/init.lua b/system/init.lua
index 926370c..e99d0d4 100644
--- a/system/init.lua
+++ b/system/init.lua
@@ -78,17 +78,8 @@ do -- autotermrestore
78 78
79 79
80 local add_gc_method do 80 local add_gc_method do
81 -- feature detection; __GC meta-method, not available in all Lua versions 81 -- __gc meta-method is not available in all Lua versions
82 local has_gc = false 82 local has_gc = not newproxy or false -- `__gc` was added when `newproxy` was removed
83 local tt = setmetatable({}, { -- luacheck: ignore
84 __gc = function() has_gc = true end
85 })
86
87 -- clear table and run GC to trigger
88 tt = nil
89 collectgarbage()
90 collectgarbage()
91
92 83
93 if has_gc then 84 if has_gc then
94 -- use default GC mechanism since it is available 85 -- use default GC mechanism since it is available
@@ -120,8 +111,7 @@ do -- autotermrestore
120 return nil, "global terminal backup was already set up" 111 return nil, "global terminal backup was already set up"
121 end 112 end
122 global_backup = system.termbackup() 113 global_backup = system.termbackup()
123 add_gc_method(global_backup, function(self) 114 add_gc_method(global_backup, function(self) pcall(system.termrestore, self) end)
124 system.termrestore(self) end)
125 return true 115 return true
126 end 116 end
127 117