Skip to content

Instantly share code, notes, and snippets.

@nviennot
Created February 3, 2015 16:57
Show Gist options
  • Save nviennot/011bfdf4cdc9deece3ac to your computer and use it in GitHub Desktop.
Save nviennot/011bfdf4cdc9deece3ac to your computer and use it in GitHub Desktop.
Signal.trap 'SIGUSR2' do
# Using a thread because we cannot acquire mutexes in a trap context in
# ruby 2.0
Thread.new do
Thread.list.each do |thread|
next if Thread.current == thread
puts '----[ Threads ]----' + '-' * (100-19)
if thread.backtrace
puts "Thread #{thread} #{thread['label']}"
puts thread.backtrace.join("\n")
else
puts "Thread #{thread} #{thread['label']} -- no backtrace"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment