Browse Source

made external executables return despite being in a different process. yay for IPC?

pull/1/head
XeonSquared 4 years ago
parent
commit
7347c93988
1 changed files with 8 additions and 2 deletions
  1. +8
    -2
      exec/shell.lua

+ 8
- 2
exec/shell.lua View File

@@ -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


Loading…
Cancel
Save