diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-09-03 20:19:55 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-09-04 10:42:48 +0900 |
commit | 37d7ae06afb03ae5508bfd81033961559886bd6b (patch) | |
tree | 2f13ca5e917a45c2296b36c8d5473bc8a5dc71bc /test/ruby/test_io.rb | |
parent | ade240e5785eac173978304ca9acfe10d08f057e (diff) |
[Bug #20708] Retry `open` on EINTR
Co-Authored-By: Martin Dorey <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11537
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 8b4dc1ed98..1ca05ae362 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3876,8 +3876,10 @@ __END__ end def test_open_fifo_does_not_block_other_threads - mkcdtmpdir { + mkcdtmpdir do File.mkfifo("fifo") + rescue NotImplementedError + else assert_separately([], <<-'EOS') t1 = Thread.new { open("fifo", "r") {|r| @@ -3892,8 +3894,32 @@ __END__ t1_value, _ = assert_join_threads([t1, t2]) assert_equal("foo", t1_value) EOS - } - end if /mswin|mingw|bccwin|cygwin/ !~ RUBY_PLATFORM + end + end + + def test_open_fifo_restart_at_signal_intterupt + mkcdtmpdir do + File.mkfifo("fifo") + rescue NotImplementedError + else + wait = EnvUtil.apply_timeout_scale(0.1) + data = "writing to fifo" + + # Do not use assert_separately, because reading from stdin + # prevents to reproduce [Bug #20708] + assert_in_out_err(["-e", "#{<<~"begin;"}\n#{<<~'end;'}"], [], [data]) + wait, data = #{wait}, #{data.dump} + ; + begin; + trap(:USR1) {} + Thread.new do + sleep wait; Process.kill(:USR1, $$) + sleep wait; File.write("fifo", data) + end + puts File.read("fifo") + end; + end + end if Signal.list[:USR1] # Pointless on platforms without signal def test_open_flag make_tempfile do |t| |