From 044e6f12be818d6ba2f1582ec6d6177d442a9512 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 1 Feb 2018 02:56:28 +0000 Subject: win32.c: EPIPE for ERROR_NO_DATA * win32/win32.c (rb_w32_write): writing to closed pipe fails with ERROR_NO_DATA but msvcrt maps it to EINVAL. map it to EPIPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_pipe.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_pipe.rb b/test/ruby/test_pipe.rb index efca8f28c1..9fa42fd375 100644 --- a/test/ruby/test_pipe.rb +++ b/test/ruby/test_pipe.rb @@ -27,4 +27,23 @@ class TestPipe < Test::Unit::TestCase end end end + + def test_stdout_epipe + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + io = STDOUT + begin + save = io.dup + IO.popen("echo", "w", out: IO::NULL) do |f| + io.reopen(f) + Process.wait(f.pid) + assert_raise(Errno::EPIPE) do + io.print "foo\n" + end + end + ensure + io.reopen(save) + end + end; + end end -- cgit v1.2.3