# Pastebin ElspxRbF =begin # just some stuff for debugging Dir.glob"/proc/#{$$}/fd/*" do |fd| begin p fd => File.readlink(fd) rescue => ex p fd => ex end end 1.upto 20 do |n| begin p IO.for_fd(n).read_nonblock(10) rescue => ex p n => ex end end =end if $stdin.tty? file, term = IO.for_fd(11), IO.for_fd(0) else file, term = IO.for_fd(0), IO.for_fd(1) end while (ready, _, _ = select([file, term]); ready) exit unless ready.include?(file) ready.each do |fd| got = fd.gets case fd when file p file: got exit unless got when term p term: got end end sleep 1 end