[前][次][番号順一覧][スレッド一覧]

ruby-changes:37726

From: nobu <ko1@a...>
Date: Mon, 2 Mar 2015 15:50:37 +0900 (JST)
Subject: [ruby-changes:37726] nobu:r49807 (trunk): test_process.rb: remove intermediate child process

nobu	2015-03-02 15:50:28 +0900 (Mon, 02 Mar 2015)

  New Revision: 49807

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49807

  Log:
    test_process.rb: remove intermediate child process
    
    * test/ruby/test_process.rb (test_deadlock_by_signal_at_forking):
      spawn the target process directly with assert_separately and
      remove intermediate child process.

  Modified files:
    trunk/test/ruby/test_process.rb
Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 49806)
+++ test/ruby/test_process.rb	(revision 49807)
@@ -1924,68 +1924,18 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1924
   end
 
   def test_deadlock_by_signal_at_forking
-    assert_separately([], <<-INPUT, timeout: 60)
-      require 'io/wait'
-      begin
-        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)
-          exc = Marshal.load(er.read.unpack("m")[0])
-          if exc.kind_of? Interrupt
-            # Don't raise Interrupt.  It aborts test-all.
-            flunk "timeout"
-          else
-            raise exc
-          end
-        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
+    assert_separately(["-", EnvUtil.rubybin], <<-INPUT, timeout: 60)
+      ruby = ARGV.shift
+      GC.start # reduce garbage
+      GC.disable # avoid triggering CoW after forks
+      trap(:QUIT) {}
+      parent = $$
+      100.times do |i|
+        pid = fork {Process.kill(:QUIT, parent)}
+        IO.popen(ruby, 'r+'){}
+        Process.wait(pid)
+        $stdout.puts
+        $stdout.flush
       end
     INPUT
   end if defined?(fork)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]