On Wed, Feb 28, 2024 at 7:45 AM Information via ruby-talk <ruby-talk@ml.ruby-lang.org> wrote:
Is there a non-blocking version of io.eof?

- how to read until eof? (and than do other things)

There is not a non-blocking version of IO#eof?.  That method works by attempting to read a byte and putting it back if successful, and it was coded to always block, much like IO#read.

If you want to perform non-blocking reads until the end of the file is reached, require in the io/nonblock extension and use IO#read_nonblock.  It's a bit more limited than IO#read, but it will return bytes if they're available, raise an exception (EOFError) if the end of file was reached, or raise an exception (IO::EAGAINWaitReadable) if the read would block because there is currently no data available.  See more details here: https://apidock.com/ruby/IO/read_nonblock.

-Jeremy