diff options
author | Christian Pointner <equinox@spreadspace.org> | 2010-11-20 03:54:03 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2010-11-20 03:54:03 +0000 |
commit | ed2b30813416ac267a9eb058fff5d004a8af1c79 (patch) | |
tree | 511bf02dc1c602d9d676985489e4dbe317ed41e1 /src/main_loop.lua | |
parent | cleanup (diff) |
added first verion of
- waitpid
- exec
- pipe
fixed timeout at select
git-svn-id: https://svn.spreadspace.org/gcsd/trunk@44 ac14a137-c7f1-4531-abe0-07747231d213
Diffstat (limited to 'src/main_loop.lua')
-rw-r--r-- | src/main_loop.lua | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main_loop.lua b/src/main_loop.lua index c310cdb..c186722 100644 --- a/src/main_loop.lua +++ b/src/main_loop.lua @@ -74,6 +74,13 @@ function main_loop(opt) log.printf(log.NOTICE, "main_loop started") local sig = signal.init() + local pid, err = util.exec("./tmp.sh") + if(pid == nil) then + log.printf(log.DEBUG, "exec script failed: %s", err) + else + log.printf(log.DEBUG, "script started with pid %d", pid) + end + local return_value = module_list:init(opt) if(return_value == defines.KILL_DAEMON) then return_value = -1 @@ -85,7 +92,12 @@ function main_loop(opt) local readable, writeable, err = util.select({ sig, unpack(get_readables()) }, get_writeables(), 10) if(err) then if(err == "timeout") then - -- TODO: handle timeouts + 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: %d", pid, reason, status) + end elseif(err == "signal") then -- ignore this else |