Compare commits
No commits in common. "216e0a15c67177cc8ef3232eb7160876885abce6" and "be3d3c207fd7a433c99db67337eed42049154a7f" have entirely different histories.
216e0a15c6
...
be3d3c207f
@ -7,7 +7,10 @@ end
|
|||||||
function runfile(p,...) -- string -- -- runs file *p* with arbitrary arguments in the current thread
|
function runfile(p,...) -- string -- -- runs file *p* with arbitrary arguments in the current thread
|
||||||
return loadfile(p)(...)
|
return loadfile(p)(...)
|
||||||
end
|
end
|
||||||
|
function os.spawnfile(p,n,...) -- string string -- number -- spawns a new process from file *p* with name *n*, with arguments following *n*.
|
||||||
|
local tA = {...}
|
||||||
|
return os.spawn(function() local res={pcall(loadfile(p), table.unpack(tA))} computer.pushSignal("process_finished", os.pid(), table.unpack(res)) dprint(table.concat(res)) end,n or p)
|
||||||
|
end
|
||||||
_G.package = {}
|
_G.package = {}
|
||||||
package.path="./?;./?.lua;/boot/lib/?.lua;/pkg/lib/?.lua;/boot/lib/?/init.lua;/pkg/lib/?/init.lua"
|
package.path="./?;./?.lua;/boot/lib/?.lua;/pkg/lib/?.lua;/boot/lib/?/init.lua;/pkg/lib/?/init.lua"
|
||||||
package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer}
|
package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer}
|
||||||
|
@ -2,13 +2,7 @@ do
|
|||||||
local tTasks,nPid,nTimeout,cPid = {},1,0.25,0 -- table of tasks, next process ID, event timeout, current PID
|
local tTasks,nPid,nTimeout,cPid = {},1,0.25,0 -- table of tasks, next process ID, event timeout, current PID
|
||||||
function os.spawn(f,n) -- function string -- number -- creates a process from function *f* with name *n*
|
function os.spawn(f,n) -- function string -- number -- creates a process from function *f* with name *n*
|
||||||
tTasks[nPid] = {
|
tTasks[nPid] = {
|
||||||
c=coroutine.create(function()
|
c=coroutine.create(f), -- actual coroutine
|
||||||
local rt = {pcall(f)}
|
|
||||||
if not rt[1] then
|
|
||||||
syslog(rt[2])
|
|
||||||
end
|
|
||||||
computer.pushSignal("process_finished",os.pid(),table.unpack(rt))
|
|
||||||
end), -- actual coroutine
|
|
||||||
n=n, -- process name
|
n=n, -- process name
|
||||||
p=nPid, -- process PID
|
p=nPid, -- process PID
|
||||||
P=cPid, -- parent PID
|
P=cPid, -- parent PID
|
||||||
|
Loading…
Reference in New Issue
Block a user