summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-17 08:45:57 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-17 08:45:57 +0000
commit813b5f43cb44a64a7630bc3858e85caa607f8105 (patch)
treeec23f8ddc07464431d39861fd65fbe2c9a5b5bfa /io.c
parent190241f371d68506dc267a598caf344583fb41dd (diff)
merge revision(s) 51066: [Backport #11319]
* io.c (rb_io_oflags_modestr): handle O_TRUNC correctly * test/ruby/test_io.rb (test_reopen_stdio): new test Patch-by: cremno phobia <cremno@mail.ru> [ruby-core:69779] [Bug #11319] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/io.c b/io.c
index 95229903ca..b86ebe8e7f 100644
--- a/io.c
+++ b/io.c
@@ -4958,6 +4958,9 @@ rb_io_oflags_modestr(int oflags)
case O_WRONLY:
return MODE_BINARY("w", "wb");
case O_RDWR:
+ if (oflags & O_TRUNC) {
+ return MODE_BINARY("w+", "wb+");
+ }
return MODE_BINARY("r+", "rb+");
}
}