diff --git a/exec/shell.lua b/exec/shell.lua index e70eca4..09ed6bc 100644 --- a/exec/shell.lua +++ b/exec/shell.lua @@ -26,11 +26,17 @@ setmetatable(shenv,{__index=function(_,k) if _G[k] then return _G[k] elseif fs.exists("/boot/exec/"..k..".lua") then + local rqid = string.format("shell-%d",math.random(1,99999)) return function(...) local tA = {...} - local pid = os.spawn(function() loadfile("/boot/exec/"..k..".lua")(table.unpack(tA)) end,"/boot/exec/"..k..".lua") + local pid = os.spawn(function() computer.pushSignal(rqid,pcall(loadfile("/boot/exec/"..k..".lua"),table.unpack(tA))) end,"/boot/exec/"..k..".lua") + local tE = {} repeat - coroutine.yield() + tE = {coroutine.yield()} + if tE[1] == rqid then + table.remove(tE,1) + return table.unpack(tE) + end until tTasks[pid] == nil end end