diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-10 03:37:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-10 03:37:09 +0000 |
commit | 047604ad9b70a5895b7272ff5e34aa20ab79405f (patch) | |
tree | 3267aeda9606410297d9bf3eeba97972faba58e1 /io.c | |
parent | dd2ebf4d786ddda1482b6419887c3f6ecbc68567 (diff) | |
download | ruby-047604ad9b70a5895b7272ff5e34aa20ab79405f.tar.gz |
io.c: reduce isatty on Cygwin [ci skip]
* io.c (prep_io): reduce isatty call (and its system call) on
Cygwin.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -5518,11 +5518,13 @@ rb_fdopen(int fd, const char *modestr) return file; } -static void +static int io_check_tty(rb_io_t *fptr) { - if (isatty(fptr->fd)) + int t = isatty(fptr->fd); + if (t) fptr->mode |= FMODE_TTY|FMODE_DUPLEX; + return t; } static VALUE rb_io_internal_encoding(VALUE); @@ -7370,14 +7372,13 @@ prep_io(int fd, int fmode, VALUE klass, const char *path) MakeOpenFile(io, fp); fp->fd = fd; + fp->mode = fmode; + if (!io_check_tty(fp)) { #ifdef __CYGWIN__ - if (!isatty(fd)) { - fmode |= FMODE_BINMODE; + fp->fmode |= FMODE_BINMODE; setmode(fd, O_BINARY); - } #endif - fp->mode = fmode; - io_check_tty(fp); + } if (path) fp->pathv = rb_obj_freeze(rb_str_new_cstr(path)); rb_update_max_fd(fd); |