Skip to content

Instantly share code, notes, and snippets.

@liluo
Forked from jarmo/all-out.txt
Created April 1, 2017 07:42
Show Gist options
  • Save liluo/1f443c9c33f43dacdecf86828e54b4e0 to your computer and use it in GitHub Desktop.
Save liluo/1f443c9c33f43dacdecf86828e54b4e0 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