From 5938f75f4c524719311ce763dcc74794a20b80cd Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 29 Jun 2020 15:25:58 +1000 Subject: [PATCH] added a process_finished event and added syslog error reporting --- module/sched.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/module/sched.lua b/module/sched.lua index f06fd91..c6f8955 100644 --- a/module/sched.lua +++ b/module/sched.lua @@ -2,7 +2,13 @@ do 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* tTasks[nPid] = { - c=coroutine.create(f), -- actual coroutine + c=coroutine.create(function() + 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 p=nPid, -- process PID P=cPid, -- parent PID