summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-18 04:22:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-18 04:22:44 +0000
commit1d1ee07f3c340dc1f18564e0b84271f759511cf0 (patch)
treeae36ddd13742bb75270266241d7070123857bfb1 /ruby.c
parent3d61b259ffcfb0dcc1e3b1b540b1cd18842bdff8 (diff)
ruby.c: disable nonblock only if nonblocking mode
* ruby.c (open_load_file): disable O_NONBLOCK only when opened in non-blocking mode, to get rid of LoadError on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ruby.c b/ruby.c
index b0fee64..35f343a 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1738,13 +1738,15 @@ open_load_file(VALUE fname_v, int *xflag)
int fd;
/* open(2) may block if fname is point to FIFO and it's empty. Let's
use O_NONBLOCK. */
- int mode = O_RDONLY;
#if defined O_NONBLOCK && HAVE_FCNTL && !(O_NONBLOCK & O_ACCMODE)
/* TODO: fix conflicting O_NONBLOCK in ruby/win32.h */
- mode |= O_NONBLOCK;
+# define MODE_TO_LOAD (O_RDONLY | O_NONBLOCK)
#elif defined O_NDELAY && HAVE_FCNTL && !(O_NDELAY & O_ACCMODE)
- mod |= O_NDELAY;
+# define MODE_TO_LOAD (O_RDONLY | O_NDELAY)
+#else
+# define MODE_TO_LOAD (O_RDONLY)
#endif
+ int mode = MODE_TO_LOAD;
#if defined DOSISH || defined __CYGWIN__
{
const char *ext = strrchr(fname, '.');
@@ -1760,7 +1762,7 @@ open_load_file(VALUE fname_v, int *xflag)
}
rb_update_max_fd(fd);
-#ifdef HAVE_FCNTL
+#if defined HAVE_FCNTL && MODE_TO_LOAD != O_RDONLY
/* disabling O_NONBLOCK */
if (fcntl(fd, F_SETFL, 0) < 0) {
e = errno;