diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-22 06:55:20 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-22 06:55:20 +0000 |
commit | a3e8d63a758dd32c01159f2ca8a980223ada300e (patch) | |
tree | eaca70426fccf74f58aa13e2cb118381d0fcd8bf /io.c | |
parent | 7e4ca5266944acabab84283fab88f35cfcfeb56e (diff) | |
download | ruby-a3e8d63a758dd32c01159f2ca8a980223ada300e.tar.gz |
* include/ruby/win32.h, win32/win32.c (rb_w32_is_valid_fd): new function
to validate fd.
* io.c (rb_io_initialize): check fd with above function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; |