From a5be27e2cf41d22a5fa57bd9fe8566acf7dde0cd Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 3 Aug 2006 16:30:46 +0000 Subject: [PATCH] * 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 --- ChangeLog | 5 +++++ io.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8449c57d4d..60c84485d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Aug 4 01:28:19 2006 Tanaka Akira + + * io.c (io_reopen): STDERR.reopen(File.open("/dev/null", "w")) should + not fclose stderr. + Thu Aug 3 15:16:44 2006 Yukihiro Matsumoto * range.c (range_include): should always call Enumerable#include? diff --git a/io.c b/io.c index 87435a3e38..0749d0fb45 100644 --- a/io.c +++ b/io.c @@ -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);