aboutsummaryrefslogtreecommitdiffstats
path: root/spec/rubyspec/core
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-10 14:18:23 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-10 14:18:23 +0000
commit525844f2578fbaf7b06c5bf7a1f36741fa149fbb (patch)
treecdc3bd7e7321ab81928774bd75c6afb60283edfc /spec/rubyspec/core
parentc66852b812817b847b7369661598c00884faae42 (diff)
downloadruby-525844f2578fbaf7b06c5bf7a1f36741fa149fbb.tar.gz
Use the Mutex to know whether we entered the signal handler in Process#kill specs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/core')
-rw-r--r--spec/rubyspec/core/process/fixtures/kill.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/spec/rubyspec/core/process/fixtures/kill.rb b/spec/rubyspec/core/process/fixtures/kill.rb
index abc8a2db2d..00b5223b90 100644
--- a/spec/rubyspec/core/process/fixtures/kill.rb
+++ b/spec/rubyspec/core/process/fixtures/kill.rb
@@ -9,16 +9,13 @@ ruby_exe = ARGV.shift
# 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
system(*ruby_exe.split(' '), "-e", code)
end
-sleep 0.001 until signaled
+sleep 0.001 until mutex.locked? and $signaled