summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-11-20 15:33:32 +0000
committerTed Trask <ttrask01@yahoo.com>2008-11-20 15:33:32 +0000
commitf49e484e015c94a92b5f30a4ea3b11060a09797d (patch)
tree08e0bcb7434e85857c7e1e463ebc74011135a7f8
parentca5e2751955a97ebcbdb7e0baf1306040c2c129d (diff)
downloadacf-core-f49e484e015c94a92b5f30a4ea3b11060a09797d.tar.bz2
acf-core-f49e484e015c94a92b5f30a4ea3b11060a09797d.tar.xz
Modified processinfo to fix problem with detecting pid file. It now also checks for matching proc directory.release-0.4.13
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1604 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--lib/processinfo.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/processinfo.lua b/lib/processinfo.lua
index 2a7392e..f071ed0 100644
--- a/lib/processinfo.lua
+++ b/lib/processinfo.lua
@@ -184,7 +184,19 @@ local function has_pidfile(name)
local file = f:read("*a")
f:close()
if file and string.find(file, "%w") then
- pid = fs.read_file(string.match(file, "^%s*(.*%S)"))
+ -- check to see if there's a matching proc directory and that it was created slightly after the pid file
+ -- this allows us to find init scripts with differing process names and avoids the problem with
+ -- proc numbers wrapping
+ file = string.match(file, "^%s*(.*%S)")
+ local tmp = string.match(fs.read_file(file), "%d+")
+ if tmp then
+ local dir = "/proc/" .. tmp
+ filetime = posix.stat(file, "ctime")
+ dirtime = posix.stat(dir, "ctime")
+ if dirtime and (tonumber(dirtime) - tonumber(filetime) < 100) then
+ pid = tmp
+ end
+ end
end
return pid
end