From 7347c939881d3cd50d2943e7cf1a71864ca9a44d Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 28 Jul 2019 19:46:43 +1000 Subject: [PATCH] made external executables return despite being in a different process. yay for IPC? --- exec/shell.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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