ruby-changes:36572
From: akr <ko1@a...>
Date: Sun, 30 Nov 2014 17:11:54 +0900 (JST)
Subject: [ruby-changes:36572] akr:r48653 (trunk): * test/ruby/test_process.rb (test_deadlock_by_signal_at_forking): Use
akr 2014-11-30 17:11:36 +0900 (Sun, 30 Nov 2014) New Revision: 48653 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48653 Log: * test/ruby/test_process.rb (test_deadlock_by_signal_at_forking): Use assert_separately. Modified files: trunk/ChangeLog trunk/test/ruby/test_process.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 48652) +++ ChangeLog (revision 48653) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Nov 30 17:11:05 2014 Tanaka Akira <akr@f...> + + * test/ruby/test_process.rb (test_deadlock_by_signal_at_forking): Use + assert_separately. + Sun Nov 30 00:02:52 2014 Nobuyoshi Nakada <nobu@r...> * ruby.c (process_options, ruby_script): transcode script name and Index: test/ruby/test_process.rb =================================================================== --- test/ruby/test_process.rb (revision 48652) +++ test/ruby/test_process.rb (revision 48653) @@ -1918,59 +1918,64 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1918 end def test_deadlock_by_signal_at_forking - GC.start # reduce garbage - buf = '' - ruby = EnvUtil.rubybin - er, ew = IO.pipe - unless runner = IO.popen("-".freeze) - er.close - status = true - GC.disable # avoid triggering CoW after forks + assert_separately([], <<-INPUT) + require 'io/wait' begin - $stderr.reopen($stdout) - trap(:QUIT) {} - parent = $$ - 100.times do |i| - pid = fork {Process.kill(:QUIT, parent)} - IO.popen(ruby, 'r+'.freeze){} - Process.wait(pid) - $stdout.puts - $stdout.flush + GC.start # reduce garbage + buf = '' + ruby = EnvUtil.rubybin + er, ew = IO.pipe + unless runner = IO.popen("-".freeze) + er.close + status = true + GC.disable # avoid triggering CoW after forks + begin + $stderr.reopen($stdout) + trap(:QUIT) {} + parent = $$ + 100.times do |i| + pid = fork {Process.kill(:QUIT, parent)} + IO.popen(ruby, 'r+'.freeze){} + Process.wait(pid) + $stdout.puts + $stdout.flush + end + ensure + if $! + ew.puts([Marshal.dump($!)].pack("m0")) + status = false + end + ew.close + exit!(status) + end end + ew.close + begin + loop do + runner.wait_readable(5) + runner.read_nonblock(100, buf) + end + rescue EOFError => e + _, status = Process.wait2(runner.pid) + rescue IO::WaitReadable => e + Process.kill(:INT, runner.pid) + raise Marshal.load(er.read.unpack("m")[0]) + end + assert_predicate(status, :success?) ensure - if $! - ew.puts([Marshal.dump($!)].pack("m0")) - status = false + er.close unless er.closed? + ew.close unless ew.closed? + if runner + begin + Process.kill(:TERM, runner.pid) + sleep 1 + Process.kill(:KILL, runner.pid) + rescue Errno::ESRCH + end + runner.close end - ew.close - exit!(status) - end - end - ew.close - begin - loop do - runner.wait_readable(5) - runner.read_nonblock(100, buf) - end - rescue EOFError => e - _, status = Process.wait2(runner.pid) - rescue IO::WaitReadable => e - Process.kill(:INT, runner.pid) - raise Marshal.load(er.read.unpack("m")[0]) - end - assert_predicate(status, :success?) - ensure - er.close unless er.closed? - ew.close unless ew.closed? - if runner - begin - Process.kill(:TERM, runner.pid) - sleep 1 - Process.kill(:KILL, runner.pid) - rescue Errno::ESRCH end - runner.close - end + INPUT end if defined?(fork) def test_process_detach -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/