summaryrefslogtreecommitdiff
path: root/src/main_loop.lua
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-11-23 00:39:30 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-11-23 00:39:30 +0000
commit559f5f720a33bd8b69a712a0d829ddc321f5aefe (patch)
treedad26c4fb5803d8a8a8908ca3a0d1b4ab38e4c09 /src/main_loop.lua
parentmainloop now handles all return codes for writer as well (diff)
exec and waitpid work with lua table for each child
git-svn-id: https://svn.spreadspace.org/gcsd/trunk@56 ac14a137-c7f1-4531-abe0-07747231d213
Diffstat (limited to 'src/main_loop.lua')
-rw-r--r--src/main_loop.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main_loop.lua b/src/main_loop.lua
index 3211660..22809aa 100644
--- a/src/main_loop.lua
+++ b/src/main_loop.lua
@@ -85,11 +85,14 @@ function main_loop(opt)
local readable, writeable, err = util.select({ sig, unpack(get_readables()) }, get_writeables(), 10)
if(err) then
if(err == "timeout") then
- local pid, reason, status = util.waitpid()
- if(pid == nil) then
- log.printf(log.DEBUG, "waitpid failed: " .. reason)
- elseif(pid > 0) then
- log.printf(log.DEBUG, "child with pid %d stopped, reason: %s, code: %s", pid, reason, tostring(status))
+ local child, reason, status = util.waitpid()
+ if(child == nil) then
+ if(reason ~= nil) then
+ log.printf(log.DEBUG, "waitpid failed: " .. reason)
+ end
+ else
+ log.printf(log.DEBUG, "child with pid %d stopped, reason: %s, code: %s", child.pid, reason, tostring(status))
+ if(child.cleanup ~= nil) then child:cleanup() end
end
elseif(err == "signal") then
-- ignore this