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): STDERR.reopen(File.open("/dev/null", "w")) should

not fclose stderr.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2006-08-03 16:30:46 +00:00
parent bba7dd4630
commit a5be27e2cf
2 changed files with 9 additions and 2 deletions

View file

@ -1,3 +1,8 @@
Fri Aug 4 01:28:19 2006 Tanaka Akira <akr@fsij.org>
* io.c (io_reopen): STDERR.reopen(File.open("/dev/null", "w")) should
not fclose stderr.
Thu Aug 3 15:16:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (range_include): should always call Enumerable#include?

6
io.c
View file

@ -3412,6 +3412,7 @@ io_reopen(VALUE io, VALUE nfile)
OpenFile *fptr, *orig;
int fd, fd2;
off_t pos = 0;
int fptr_is_prep_stdio;
nfile = rb_io_get_io(nfile);
if (rb_safe_level() >= 4 && (!OBJ_TAINTED(io) || !OBJ_TAINTED(nfile))) {
@ -3422,7 +3423,8 @@ io_reopen(VALUE io, VALUE nfile)
if (fptr == orig) return io;
#if !defined __CYGWIN__
if (IS_PREP_STDIO(fptr)) {
fptr_is_prep_stdio = IS_PREP_STDIO(fptr);
if (fptr_is_prep_stdio) {
if (((fptr->mode & FMODE_READWRITE) & (orig->mode & FMODE_READWRITE)) !=
(fptr->mode & FMODE_READWRITE)) {
rb_raise(rb_eArgError,
@ -3455,7 +3457,7 @@ io_reopen(VALUE io, VALUE nfile)
fd2 = orig->fd;
if (fd != fd2) {
#if !defined __CYGWIN__
if (IS_PREP_STDIO(fptr)) {
if (fptr_is_prep_stdio) {
/* need to keep stdio objects */
if (dup2(fd2, fd) < 0)
rb_sys_fail(orig->path);