summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-24 19:59:51 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-24 19:59:51 (GMT)
commit608b9c29133e6d4c0822f1500e45c2a8073891be (patch)
treed85d0bff2e670fa6186f865d6d63997839fbe07b /io.c
parentcc6020b7aacc4f746dede34d050dc698ae2d2312 (diff)
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
Diffstat (limited to 'io.c')
-rw-r--r--io.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/io.c b/io.c
index da3fcfc5..4a3f152 100644
--- a/io.c
+++ b/io.c
@@ -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;
}