summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-11 09:30:19 +0900
committerGitHub <noreply@github.com>2020-04-11 09:30:19 +0900
commit6f28ebd585fba1aff1c9591ced08ed11b68ba9e3 (patch)
treec807e4234379a4dd8da80cf33a5329284d84cb12 /test/ruby
parent87bcb3c47c7369fe285b2c7c670476a8d4553d82 (diff)
downloadruby-6f28ebd585fba1aff1c9591ced08ed11b68ba9e3.tar.gz
Silence broken pipe error messages on STDOUT [Feature #14413]
Raise `SignalException` for SIGPIPE to abort when EPIPE occurs.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index a49fd0130e..9dc0debe16 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -3952,4 +3952,22 @@ __END__
assert_raise(TypeError) {Marshal.dump(w)}
}
end
+
+ def test_stdout_to_closed_pipe
+ EnvUtil.invoke_ruby(["-e", "loop {puts :ok}"], "", true, true) do
+ |in_p, out_p, err_p, pid|
+ out = out_p.gets
+ out_p.close
+ err = err_p.read
+ ensure
+ status = Process.wait2(pid)[1]
+ assert_equal("ok\n", out)
+ assert_empty(err)
+ assert_not_predicate(status, :success?)
+ if Signal.list["PIPE"]
+ assert_predicate(status, :signaled?)
+ assert_equal("PIPE", Signal.signame(status.termsig) || status.termsig)
+ end
+ end
+ end
end