Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Commit

Permalink
Attempt to fix Issue #747
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed May 17, 2017
1 parent 0a157b1 commit f59026a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
13 changes: 8 additions & 5 deletions lib/capybara/poltergeist/client.rb
Expand Up @@ -27,11 +27,14 @@ def self.process_killer(pid)
Process.kill('KILL', pid)
else
Process.kill('TERM', pid)
begin
Timeout.timeout(KILL_TIMEOUT) { Process.wait(pid) }
rescue Timeout::Error
Process.kill('KILL', pid)
Process.wait(pid)
start = Time.now
while Process.wait(pid, Process::WNOHANG).nil?
sleep 0.05
if (Time.now - start) > KILL_TIMEOUT
Process.kill('KILL', pid)
Process.wait(pid)
break
end
end
end
rescue Errno::ESRCH, Errno::ECHILD
Expand Down
5 changes: 1 addition & 4 deletions spec/unit/client_spec.rb
Expand Up @@ -49,10 +49,7 @@ def stub_version(version)
client = Client.new(server)

allow(Process).to receive_messages(spawn: 5678)
allow(Process).to receive(:wait) do
@count = @count.to_i + 1
@count == 1 ? sleep(3) : 0
end
allow(Process).to receive(:wait).and_return(nil)

client.start

Expand Down

0 comments on commit f59026a

Please sign in to comment.