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
This commit is contained in:
eregon 2017-05-10 14:18:23 +00:00
parent c66852b812
commit 525844f257

View File

@ -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