From 13fe01c55d24e23a17320fb38363a8fc1452ebb2 Mon Sep 17 00:00:00 2001 From: John Barker Date: Mon, 30 May 2011 13:08:57 +0800 Subject: [PATCH] Do at_exit first to make sure server is always killed, also put a select in so it fails a bit more gracefully after 10 seconds if something goes wrong with the server --- lib/capybara/driver/webkit/browser.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/capybara/driver/webkit/browser.rb b/lib/capybara/driver/webkit/browser.rb index bde0d5a..161a89a 100644 --- a/lib/capybara/driver/webkit/browser.rb +++ b/lib/capybara/driver/webkit/browser.rb @@ -72,10 +72,11 @@ class Capybara::Driver::Webkit read_pipe.close exec(server_path) end - write_pipe.close - @server_port = ((read_pipe.first || '').match(/listening on port: (\d+)/) || [])[1] - at_exit { Process.kill("INT", @pid) } + + write_pipe.close + return unless IO.select([read_pipe], nil, nil, 10) + @server_port = ((read_pipe.first || '').match(/listening on port: (\d+)/) || [])[1] end def connect