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:
parent
40ced763b4
commit
56ca006784
1 changed files with 10 additions and 2 deletions
|
@ -72,20 +72,28 @@ module EnvUtil
|
||||||
end
|
end
|
||||||
module_function :timeout
|
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
|
reprieve = apply_timeout_scale(reprieve) if reprieve
|
||||||
|
|
||||||
signals = Array(signal).select do |sig|
|
signals = Array(signal).select do |sig|
|
||||||
DEFAULT_SIGNALS[sig.to_s] or
|
DEFAULT_SIGNALS[sig.to_s] or
|
||||||
DEFAULT_SIGNALS[Signal.signame(sig)] rescue false
|
DEFAULT_SIGNALS[Signal.signame(sig)] rescue false
|
||||||
end
|
end
|
||||||
signals |= [:SEGV, :ABRT, :KILL]
|
signals |= [:ABRT, :KILL]
|
||||||
case pgroup
|
case pgroup
|
||||||
when 0, true
|
when 0, true
|
||||||
pgroup = -pid
|
pgroup = -pid
|
||||||
when nil, false
|
when nil, false
|
||||||
pgroup = pid
|
pgroup = pid
|
||||||
end
|
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
|
while signal = signals.shift
|
||||||
begin
|
begin
|
||||||
Process.kill signal, pgroup
|
Process.kill signal, pgroup
|
||||||
|
|
Loading…
Reference in a new issue