1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

io.c: disable nonblocking-by-default on win32 pipes

Lets admit Windows will always be too different from POSIX-like
platforms and non-blocking may never work as well or consistently.

[ruby-core:90042] [ruby-core:90044] [Bug #14968]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2018-11-24 19:59:51 +00:00
parent cc6020b7aa
commit 608b9c2913

16
io.c
View file

@ -135,6 +135,14 @@ off_t __syscall(quad_t number, ...);
#define rename(f, t) rb_w32_urename((f), (t))
#endif
#if defined(_WIN32)
# define RUBY_PIPE_NONBLOCK_DEFAULT (0)
#elif defined(O_NONBLOCK)
# define RUBY_PIPE_NONBLOCK_DEFAULT (O_NONBLOCK)
#else /* any platforms where O_NONBLOCK does not exist? */
# define RUBY_PIPE_NONBLOCK_DEFAULT (0)
#endif
VALUE rb_cIO;
VALUE rb_eEOFError;
VALUE rb_eIOError;
@ -345,7 +353,7 @@ rb_cloexec_pipe(int fildes[2])
#if defined(HAVE_PIPE2)
static int try_pipe2 = 1;
if (try_pipe2) {
ret = pipe2(fildes, O_CLOEXEC | O_NONBLOCK);
ret = pipe2(fildes, O_CLOEXEC | RUBY_PIPE_NONBLOCK_DEFAULT);
if (ret != -1)
return ret;
/* pipe2 is available since Linux 2.6.27, glibc 2.9. */
@ -371,8 +379,10 @@ rb_cloexec_pipe(int fildes[2])
#endif
rb_maygvl_fd_fix_cloexec(fildes[0]);
rb_maygvl_fd_fix_cloexec(fildes[1]);
rb_fd_set_nonblock(fildes[0]);
rb_fd_set_nonblock(fildes[1]);
if (RUBY_PIPE_NONBLOCK_DEFAULT) {
rb_fd_set_nonblock(fildes[0]);
rb_fd_set_nonblock(fildes[1]);
}
return ret;
}