1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* io.c (io_reopen): don't change access mode for stdin, stdout and

stderr.  [ruby-core:15360]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-02-07 07:40:25 +00:00
parent 89941dffb5
commit 82b088aa0c
3 changed files with 28 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Thu Feb 7 16:33:51 2008 Tanaka Akira <akr@fsij.org>
* io.c (io_reopen): don't change access mode for stdin, stdout and
stderr. [ruby-core:15360]
Thu Feb 7 16:33:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Feb 7 16:33:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (str_replace_shared): replaces string with sharing. * string.c (str_replace_shared): replaces string with sharing.

View file

@ -36,3 +36,19 @@ assert_finish 1, %q{
} }
r.gets("abab") r.gets("abab")
} }
assert_equal 'ok', %q{
require 'tmpdir'
begin
tmpname = "#{Dir.tmpdir}/ruby-btest-#{$$}-#{rand(0x100000000).to_s(36)}"
rw = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL)
rescue Errno::EEXIST
retry
end
save = STDIN.dup
STDIN.reopen(rw)
STDIN.reopen(save)
rw.close
File.unlink(tmpname)
:ok
}

8
io.c
View file

@ -4132,7 +4132,13 @@ io_reopen(VALUE io, VALUE nfile)
} }
/* copy rb_io_t structure */ /* copy rb_io_t structure */
fptr->mode = orig->mode | (fptr->mode & FMODE_PREP); if (fptr->mode & FMODE_PREP) {
int mask = FMODE_PREP|FMODE_READWRITE;
fptr->mode = (orig->mode & ~mask)|(fptr->mode & mask);
}
else {
fptr->mode = orig->mode;
}
fptr->pid = orig->pid; fptr->pid = orig->pid;
fptr->lineno = orig->lineno; fptr->lineno = orig->lineno;
if (fptr->path) free(fptr->path); if (fptr->path) free(fptr->path);