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

ruby-changes:46530

From: eregon <ko1@a...>
Date: Wed, 10 May 2017 23:18:28 +0900 (JST)
Subject: [ruby-changes:46530] eregon:r58651 (trunk): Use the Mutex to know whether we entered the signal handler in Process#kill specs

eregon	2017-05-10 23:18:23 +0900 (Wed, 10 May 2017)

  New Revision: 58651

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

  Log:
    Use the Mutex to know whether we entered the signal handler in Process#kill specs

  Modified files:
    trunk/spec/rubyspec/core/process/fixtures/kill.rb
Index: spec/rubyspec/core/process/fixtures/kill.rb
===================================================================
--- spec/rubyspec/core/process/fixtures/kill.rb	(revision 58650)
+++ spec/rubyspec/core/process/fixtures/kill.rb	(revision 58651)
@@ -9,16 +9,13 @@ ruby_exe = ARGV.shift https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/process/fixtures/kill.rb#L9
 # instead, which will likely abort the specs process.
 Process.setsid if scenario
 
-signaled = false
 mutex = Mutex.new
 
 Signal.trap(:TERM) do
   if mutex.try_lock
-    unless signaled
-      signaled = true
-      STDOUT.puts "signaled"
-      STDOUT.flush
-    end
+    STDOUT.puts "signaled"
+    STDOUT.flush
+    $signaled = true
   end
 end
 
@@ -46,4 +43,4 @@ if scenario https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/process/fixtures/kill.rb#L43
   system(*ruby_exe.split(' '), "-e", code)
 end
 
-sleep 0.001 until signaled
+sleep 0.001 until mutex.locked? and $signaled

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

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