diff --git a/core/src/main/java/org/jruby/util/io/OpenFile.java b/core/src/main/java/org/jruby/util/io/OpenFile.java index 846dbad3b78..a2ef5703f0f 100644 --- a/core/src/main/java/org/jruby/util/io/OpenFile.java +++ b/core/src/main/java/org/jruby/util/io/OpenFile.java @@ -1571,7 +1571,11 @@ private static void selectForRead(ThreadContext context, OpenFile fptr, ChannelF if (fd.chSelect != null && fd.chNative == null // MRI does not select for rb_read_internal on native descriptors && !fptr.nonblock) { - context.getThread().select(fd.chSelect, fptr, SelectionKey.OP_READ); + + // keep selecting for read until ready, polling each time we wake up + while (!context.getThread().select(fd.chSelect, fptr, SelectionKey.OP_READ)) { + context.pollThreadEvents(); + } } } finally { fptr.lock();