Skip to content

Commit e2cd74f

Browse files
authored
Implement os.exit
Completely untested, but should work.
1 parent 98ebfc1 commit e2cd74f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

miniOS/minios.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,10 @@ os.sleep = function(timeout)
11711171
until computer.uptime() >= deadline
11721172
end
11731173

1174+
os.exit = function(code)
1175+
error({[1]="INTERRUPT", [2]="EXIT", [3]=code})
1176+
end
1177+
11741178
--set up terminal
11751179
if term.isAvailable() then
11761180
component.gpu.bind(component.screen.address)
@@ -1195,7 +1199,8 @@ miniOS = {}
11951199
local function interrupt(data)
11961200
--print("INTERRUPT!")
11971201
if data[2] == "RUN" then return miniOS.runfile(data[3], table.unpack(data[4])) end
1198-
if data[3] == "ERR" then error("This error is for testing!") end
1202+
if data[2] == "ERR" then error("This error is for testing!") end
1203+
if data[2] == "EXIT" then return data[3] end
11991204
end
12001205
local function runfile(file, ...)
12011206
local program, reason = loadfile(file)

0 commit comments

Comments
 (0)