From 1fe90db5380117580ae41be4f3d01686aaa73697 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 25 Oct 2014 13:34:21 +0000 Subject: [PATCH] * io.c (io_binwrite_string): Test writev() failure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ io.c | 3 +++ test/ruby/test_io.rb | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index c21dddc440..17a6a36864 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Oct 25 22:28:17 2014 Tanaka Akira + + * io.c (io_binwrite_string): Test writev() failure. + Sat Oct 25 20:19:19 2014 Martin Duerst * test/test-unicode_normalize.rb: added test_us_ascii. diff --git a/io.c b/io.c index 3a0cc01e04..290e8b1de3 100644 --- a/io.c +++ b/io.c @@ -1276,6 +1276,9 @@ io_binwrite_string(VALUE arg) r = rb_writev_internal(fptr->fd, iov, 2); + if (r == -1) + return -1; + if (fptr->wbuf.len <= r) { r -= fptr->wbuf.len; fptr->wbuf.off = 0; diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 557ad0897b..18157fabf1 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1370,6 +1370,17 @@ class TestIO < Test::Unit::TestCase end end + def test_close_read_pipe_nosync + assert_separately([], <<-"end;") + r, w = IO.pipe + r.close + w.sync = false + assert_raise(Errno::EPIPE) { + loop { w.write "a" } + } + end; + end + def test_close_read_non_readable with_pipe do |r, w| assert_raise(IOError) do