class IO::Stream::Buffered
def sysread(size, buffer)
def sysread(size, buffer) # Come on Ruby, why couldn't this just return `nil`? EOF is not exceptional. Every file has one. while true result = @io.read_nonblock(size, buffer, exception: false) case result when :wait_readable @io.wait_readable(@io.timeout) or raise ::IO::TimeoutError, "read timeout" when :wait_writable @io.wait_writable(@io.timeout) or raise ::IO::TimeoutError, "write timeout" else return result end end rescue Errno::EBADF raise ::IOError, "stream closed" end