Skip to content

Instantly share code, notes, and snippets.

@jarmo
Created July 14, 2012 15:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jarmo/3111825 to your computer and use it in GitHub Desktop.
Save jarmo/3111825 to your computer and use it in GitHub Desktop.
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>'
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
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
trap 'INT' do
STDERR.puts "Current thread: #{Thread.inspect}"
STDERR.puts caller.join("\n \\_ ")
end
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
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