Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

require 'socket'
socket = TCPSocket.new('127.0.0.1', 80)
# In JRuby 1.7.10, reading 0 bytes blocks the caller.
# In MRI 1.9.3 and 2.1.1, reading 0 bytes immediately returns an empty string.
socket.read(0)
@unclebilly
unclebilly / backtrace_printer
Last active August 29, 2015 13:57
Handle the USR1 signal by printing backtraces
#!/usr/bin/env ruby
puts "PID: #{$$}"
trap("USR1") do
@dump = true
end
t = Thread.new do
loop do
print '<'