aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/io.c b/io.c
index 5555de7c26..c62af6ee35 100644
--- a/io.c
+++ b/io.c
@@ -5971,13 +5971,15 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
fd = NUM2INT(fnum);
if (fstat(fd, &st) == -1) rb_sys_fail(0);
UPDATE_MAXFD(fd);
- if (NIL_P(vmode)) {
#if defined(HAVE_FCNTL) && defined(F_GETFL)
+ if (NIL_P(vmode)) {
oflags = fcntl(fd, F_GETFL);
if (oflags == -1) rb_sys_fail(0);
fmode = rb_io_oflags_fmode(oflags);
-#endif
}
+#elif defined(_WIN32)
+ if (rb_w32_is_valid_fd(fd)) rb_sys_fail(0);
+#endif
MakeOpenFile(io, fp);
fp->fd = fd;
fp->mode = fmode;