ruby-changes:53745
From: normal <ko1@a...>
Date: Sun, 25 Nov 2018 04:59:55 +0900 (JST)
Subject: [ruby-changes:53745] normal:r65962 (trunk): io.c: disable nonblocking-by-default on win32 pipes
normal 2018-11-25 04:59:51 +0900 (Sun, 25 Nov 2018) New Revision: 65962 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65962 Log: 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] Modified files: trunk/io.c Index: io.c =================================================================== --- io.c (revision 65961) +++ io.c (revision 65962) @@ -135,6 +135,14 @@ off_t __syscall(quad_t number, ...); https://github.com/ruby/ruby/blob/trunk/io.c#L135 #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]) https://github.com/ruby/ruby/blob/trunk/io.c#L353 #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]) https://github.com/ruby/ruby/blob/trunk/io.c#L379 #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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/