Skip to content

Commit

Permalink
Merge pull request sidekiq#2652 from sisnkemp/getpgid_to_kill
Browse files Browse the repository at this point in the history
Process.kill to check for process is more portable.
  • Loading branch information
mperham committed Nov 10, 2015
2 parents dd600a3 + a6ea55d commit 8cac86b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/sidekiqctl
Expand Up @@ -41,9 +41,13 @@ class Sidekiqctl
end

def fetch_process
Process.getpgid(pid)
Process.kill(0, pid)
rescue Errno::ESRCH
done "Process doesn't exist", :error
# We were not allowed to send a signal, but the process must have existed
# when Process.kill() was called.
rescue Errno::EPERM
return pid
end

def done(msg, error = nil)
Expand All @@ -67,10 +71,12 @@ class Sidekiqctl
`kill -TERM #{pid}`
kill_timeout.times do
begin
Process.getpgid(pid)
Process.kill(0, pid)
rescue Errno::ESRCH
FileUtils.rm_f pidfile
done 'Sidekiq shut down gracefully.'
rescue Errno::EPERM
done 'Not permitted to shut down Sidekiq.'
end
sleep 1
end
Expand Down

0 comments on commit 8cac86b

Please sign in to comment.