def sweep
begin
glob = File.join(@dirname, ".*lck")
paths = Dir[glob]
paths.each do |path|
begin
basename = File.basename path
pat = %r/^\s*\.([^_]+)_([^_]+)/o
if pat.match(basename)
host, pid = $1, $2
else
next
end
host.gsub!(%r/^\.+|\.+$/,'')
quad = host.split %r/\./
host = quad.first
pat = %r/^\s*#{ host }/i
if pat.match(HOSTNAME) and %r/^\s*\d+\s*$/.match(pid)
unless alive?(pid)
trace{ "process <#{ pid }> on <#{ host }> is no longer alive" }
trace{ "sweeping <#{ path }>" }
FileUtils.rm_f path
else
trace{ "process <#{ pid }> on <#{ host }> is still alive" }
trace{ "ignoring <#{ path }>" }
end
else
trace{ "ignoring <#{ path }> generated by <#{ host }>" }
end
rescue
next
end
end
rescue => e
warn(errmsg(e))
end
end