summaryrefslogtreecommitdiff
path: root/spec/ruby/fixtures/io.rb
blob: 87ebbbb2bd4b922aa545561feeac6573eace9e1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
module IOSpec
  def self.exhaust_write_buffer(io)
    written = 0
    buf = " " * 4096

    while true
      written += io.write_nonblock(buf)
    end
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK
    written
  end
end