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:
parent
c66852b812
commit
525844f257
@ -9,16 +9,13 @@ ruby_exe = ARGV.shift
|
|||||||
# instead, which will likely abort the specs process.
|
# instead, which will likely abort the specs process.
|
||||||
Process.setsid if scenario
|
Process.setsid if scenario
|
||||||
|
|
||||||
signaled = false
|
|
||||||
mutex = Mutex.new
|
mutex = Mutex.new
|
||||||
|
|
||||||
Signal.trap(:TERM) do
|
Signal.trap(:TERM) do
|
||||||
if mutex.try_lock
|
if mutex.try_lock
|
||||||
unless signaled
|
STDOUT.puts "signaled"
|
||||||
signaled = true
|
STDOUT.flush
|
||||||
STDOUT.puts "signaled"
|
$signaled = true
|
||||||
STDOUT.flush
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -46,4 +43,4 @@ if scenario
|
|||||||
system(*ruby_exe.split(' '), "-e", code)
|
system(*ruby_exe.split(' '), "-e", code)
|
||||||
end
|
end
|
||||||
|
|
||||||
sleep 0.001 until signaled
|
sleep 0.001 until mutex.locked? and $signaled
|
||||||
|
Loading…
x
Reference in New Issue
Block a user