Commit 6537c66b authored by Craig Miskell's avatar Craig Miskell Committed by Sean McGivern

Refactor to use common method for checking process liveness

Adds critical clarifying comments about the meaning of signal 0, which
is effectively a liveness/existence (and permissions) check
See http://man7.org/linux/man-pages/man2/kill.2.html for a discussion
of that
parent 9dd56719
...@@ -137,7 +137,7 @@ module Gitlab ...@@ -137,7 +137,7 @@ module Gitlab
# Returns true if all the processes are alive. # Returns true if all the processes are alive.
def self.all_alive?(pids) def self.all_alive?(pids)
pids.each do |pid| pids.each do |pid|
return false unless signal(pid, 0) return false unless process_alive?(pid)
end end
true true
...@@ -148,7 +148,13 @@ module Gitlab ...@@ -148,7 +148,13 @@ module Gitlab
end end
def self.pids_alive(pids) def self.pids_alive(pids)
pids.select { |pid| signal(pid, 0) } pids.select { |pid| process_alive?(pid) }
end
def self.process_alive?(pid)
# Signal 0 tests whether the process exists and we have access to send signals
# but is otherwise a noop (doesn't actually send a signal to the process)
signal(pid, 0)
end end
def self.write_pid(path) def self.write_pid(path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment