module Process
# Returns +true+ the process identied by +pid+ is running.
def running?(pid)
Process.getpgid(pid) != -1
rescue Errno::EPERM
true
rescue Errno::ESRCH
false
end
module_function :running?
end参考自 Thin 的源码 https://github.com/macournoyer/thin/blob/v1.5.1/lib/thin/daemonizing.rb#L4