benchmarks icon indicating copy to clipboard operation
benchmarks copied to clipboard

Using stderr instead of sockets

Open kostya opened this issue 4 years ago • 0 comments

can simplify code by much:

how xtime can do it:

r, w = IO.pipe
pid = Process.spawn(*["ruby", "-e", "5.times do; STDERR.puts('msg'); sleep 1; end"], {err: w})

Thread.new do
  while true
    if IO.select([r])
      p r.read_nonblock(1024)
    end
  end
end

Process.wait(pid)
w.close
r.close

kostya avatar Dec 29 '20 01:12 kostya