From af9e072c7ee0e1be48eedccf442d85dec097964c Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 29 Jun 2015 23:24:56 +0000 Subject: io.c: reopen stdio streams correctly when given "w+" * io.c (rb_io_oflags_modestr): handle O_TRUNC correctly * test/ruby/test_io.rb (test_reopen_stdio): new test Patch-by: cremno phobia [ruby-core:69779] [Bug #11319] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/ruby/test_io.rb') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 9b3e80160d..9ded25b051 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2069,6 +2069,15 @@ End } end + def test_reopen_stdio + mkcdtmpdir { + fname = 'bug11319' + File.write(fname, 'hello') + system(EnvUtil.rubybin, '-e', "STDOUT.reopen('#{fname}', 'w+')") + assert_equal('', File.read(fname)) + } + end + def test_reopen_mode feature7067 = '[ruby-core:47694]' make_tempfile {|t| -- cgit v1.2.3