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

ruby-changes:61176

From: Takashi <ko1@a...>
Date: Sun, 10 May 2020 17:01:16 +0900 (JST)
Subject: [ruby-changes:61176] 967ae6278f (master): Run rb_syswait on exec failure

https://git.ruby-lang.org/ruby.git/commit/?id=967ae6278f

From 967ae6278f8429dc268f8d3252de048eba86fe29 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Sun, 10 May 2020 00:52:54 -0700
Subject: Run rb_syswait on exec failure

not only when !w but also when w == WAITPID_LOCK_ONLY.
See also: f7c0cc36920a4ed14a3ab1ca6cfdf18ceff1e5d5 and a2264342063260d660b99872eaf5080f6ab08e81.
We thought this change was an oversight in the latter commit.

Without this change, the test fails like:

$ make test-all TESTS="../test/ruby/test_process.rb -n test_exec_failure_leaves_no_child" RUN_OPTS="--jit"
...
  1) Failure:
TestProcess#test_exec_failure_leaves_no_child [/home/k0kubun/src/github.com/ruby/ruby/test/ruby/test_process.rb:2493]:
Expected [[26799, #<Process::Status: pid 26799 exit 127>]] to be empty.

Co-Authored-By: Yusuke Endoh <mame@r...>

diff --git a/process.c b/process.c
index e5cfed8..7ec3b54 100644
--- a/process.c
+++ b/process.c
@@ -4046,7 +4046,7 @@ fork_check_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, https://github.com/ruby/ruby/blob/trunk/process.c#L4046
                       "only used by extensions");
             rb_protect(proc_syswait, (VALUE)pid, status);
         }
-        else if (!w) {
+        else if (!w || w == WAITPID_LOCK_ONLY) {
             rb_syswait(pid);
         }
         errno = err;
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 7bcfa48..9d0ee67 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -2485,4 +2485,11 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L2485
     Process.wait spawn(RUBY, "-e", "exit 13")
     assert_same(Process.last_status, $?)
   end
+
+  def test_exec_failure_leaves_no_child
+    assert_raise(Errno::ENOENT) do
+      spawn('inexistent_command')
+    end
+    assert_empty(Process.waitall)
+  end
 end
diff --git a/test/rubygems/test_gem_ext_cmake_builder.rb b/test/rubygems/test_gem_ext_cmake_builder.rb
index d056202..b3f9241 100644
--- a/test/rubygems/test_gem_ext_cmake_builder.rb
+++ b/test/rubygems/test_gem_ext_cmake_builder.rb
@@ -14,14 +14,6 @@ class TestGemExtCmakeBuilder < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_ext_cmake_builder.rb#L14
       _, status = Open3.capture2e('cmake')
       skip 'cmake not present' unless status.success?
     rescue Errno::ENOENT
-      # Open3.capture2e with ENOENT with JIT enabled leaves a zombie process.
-      # TODO: avoid making the zombie on ENOENT with JIT
-      if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
-        begin
-          Process.waitall
-        rescue Errno::ECHILD
-        end
-      end
       skip 'cmake not present'
     end
 
-- 
cgit v0.10.2


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

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