diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-21 17:25:18 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-12 23:28:48 +0900 |
commit | 385033ba0fe221097637943936973d0e9bd235a9 (patch) | |
tree | 62715dea2e5ef8437ef868b24a98881c42c33899 | |
parent | 39336c1ab897cee3b9069d8650a1e2ace23d128f (diff) | |
download | ruby-385033ba0fe221097637943936973d0e9bd235a9.tar.gz |
Ensure signaled processes at opening FIFO terminated
-rw-r--r-- | test/ruby/test_process.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index dc0ccd1f77..38a29f8332 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -665,6 +665,7 @@ class TestProcess < Test::Unit::TestCase end unless windows? # does not support fifo def test_execopts_redirect_open_fifo_interrupt_raise + pid = nil with_tmpchdir {|d| begin File.mkfifo("fifo") @@ -682,15 +683,21 @@ class TestProcess < Test::Unit::TestCase puts "ok" end EOS + pid = io.pid assert_equal("start\n", io.gets) sleep 0.5 Process.kill(:USR1, io.pid) assert_equal("ok\n", io.read) } + assert_equal(pid, $?.pid) + assert_predicate($?, :success?) } + ensure + assert_raise(Errno::ESRCH) {Process.kill(:KILL, pid)} if pid end unless windows? # does not support fifo def test_execopts_redirect_open_fifo_interrupt_print + pid = nil with_tmpchdir {|d| begin File.mkfifo("fifo") @@ -703,6 +710,7 @@ class TestProcess < Test::Unit::TestCase puts "start" system("cat", :in => "fifo") EOS + pid = io.pid assert_equal("start\n", io.gets) sleep 0.2 # wait for the child to stop at opening "fifo" Process.kill(:USR1, io.pid) @@ -710,7 +718,13 @@ class TestProcess < Test::Unit::TestCase File.write("fifo", "ok\n") assert_equal("ok\n", io.read) } + assert_equal(pid, $?.pid) + assert_predicate($?, :success?) } + ensure + if pid + assert_raise(Errno::ESRCH) {Process.kill(:KILL, pid)} + end end unless windows? # does not support fifo def test_execopts_redirect_pipe |