mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
3d61b259ff
commit
1d1ee07f3c
1 changed files with 6 additions and 4 deletions
10
ruby.c
10
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;
|
||||
|
|
Loading…
Reference in a new issue