Created
July 14, 2012 15:25
-
-
Save jarmo/3111825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread-9jnxc | |
looping.rb:17:in `block (2 levels) in <main>' | |
\_ looping.rb:15:in `each' | |
\_ looping.rb:15:in `block in <main>' | |
\_ looping.rb:22:in `call' | |
\_ looping.rb:22:in `condition' | |
\_ looping.rb:26:in `looping' | |
\_ looping.rb:31:in `<main>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trap 'INT' do | |
Thread.list.each do |thread| | |
STDERR.puts "Thread-#{thread.object_id.to_s(36)}" | |
STDERR.puts thread.backtrace.join("\n \\_ ") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trap 'INT' do | |
if RUBY_VERSION =~ /^1\.8\./ | |
STDERR.puts "Current thread: #{Thread.inspect}" | |
STDERR.puts caller.join("\n \\_ ") | |
else | |
Thread.list.each do |thread| | |
STDERR.puts "Thread-#{thread.object_id.to_s(36)}" | |
STDERR.puts thread.backtrace.join("\n \\_ ") | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trap 'INT' do | |
STDERR.puts "Current thread: #{Thread.inspect}" | |
STDERR.puts caller.join("\n \\_ ") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interrupted = false | |
trap 'INT' do | |
exit Signal.list["INT"] if interrupted | |
interrupted = true | |
if RUBY_VERSION =~ /^1\.8\./ | |
STDERR.puts "Current thread: #{Thread.inspect}" | |
STDERR.puts caller.join("\n \\_ ") | |
else | |
Thread.list.each do |thread| | |
STDERR.puts "Thread-#{thread.object_id.to_s(36)}" | |
STDERR.puts thread.backtrace.join("\n \\_ ") | |
end | |
end | |
puts "Press Ctrl+C again to exit..." | |
sleep 1 | |
interrupted = false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def condition | |
true | |
end | |
def looping | |
while condition | |
# do something | |
end | |
end | |
looping |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment