class INotify::Notifier
def readpartial(size)
def readpartial(size) # Use Ruby's readpartial if possible, to avoid blocking other threads. return to_io.readpartial(size) if self.class.supports_ruby_io? tries = 0 begin tries += 1 buffer = FFI::MemoryPointer.new(:char, size) size_read = Native.read(fd, buffer, size) return buffer.read_string(size_read) if size_read >= 0 end while FFI.errno == Errno::EINTR::Errno && tries <= 5 raise SystemCallError.new("Error reading inotify events" + case FFI.errno when Errno::EAGAIN::Errno; ": no data available for non-blocking I/O" when Errno::EBADF::Errno; ": invalid or closed file descriptor" when Errno::EFAULT::Errno; ": invalid buffer" when Errno::EINVAL::Errno; ": invalid file descriptor" when Errno::EIO::Errno; ": I/O error" when Errno::EISDIR::Errno; ": file descriptor is a directory" else; "" end, FFI.errno) end