1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

run lldb to investigate the stuck process.

Before sending signals (ABRT, KILL), use lldb to show the
backtrace of a stuck process.

This commit also reverts recent changes for terminate().
This commit is contained in:
Koichi Sasada 2020-06-02 17:18:09 +09:00
parent 40ced763b4
commit 56ca006784

View file

@ -72,20 +72,28 @@ module EnvUtil
end
module_function :timeout
def terminate(pid, signal = :TERM, pgroup = nil, reprieve = 3)
def terminate(pid, signal = :TERM, pgroup = nil, reprieve = 1)
reprieve = apply_timeout_scale(reprieve) if reprieve
signals = Array(signal).select do |sig|
DEFAULT_SIGNALS[sig.to_s] or
DEFAULT_SIGNALS[Signal.signame(sig)] rescue false
end
signals |= [:SEGV, :ABRT, :KILL]
signals |= [:ABRT, :KILL]
case pgroup
when 0, true
pgroup = -pid
when nil, false
pgroup = pid
end
if /darwin/ =~ RUBY_PLATFORM
# sudo -n: --non-interactive
# lldb -p: attach
# -o: run command
puts `sudo -n lldb -p #{pid} --batch -o "bt all" -o "call rb_vmdebug_stack_dump_all_threads()" -o quit`
end
while signal = signals.shift
begin
Process.kill signal, pgroup