mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Use IO.popen to spawn webkit_server instead of fork and exec.
This makes capybara-webkit compatible with DRb (which replaces $stdout with an object that does not support #reopen). Also, by default, popen closes all nonstandard file descriptors in the spawned process, fixing problems related to #132.
This commit is contained in:
parent
dc49e5f875
commit
d8abcbcb0f
1 changed files with 7 additions and 11 deletions
|
@ -81,27 +81,23 @@ class Capybara::Driver::Webkit
|
|||
private
|
||||
|
||||
def start_server
|
||||
read_pipe, write_pipe = fork_server
|
||||
@server_port = discover_server_port(read_pipe)
|
||||
pipe = fork_server
|
||||
@server_port = discover_server_port(pipe)
|
||||
@stdout_thread = Thread.new do
|
||||
Thread.current.abort_on_exception = true
|
||||
forward_stdout(read_pipe)
|
||||
forward_stdout(pipe)
|
||||
end
|
||||
end
|
||||
|
||||
def fork_server
|
||||
server_path = File.expand_path("../../../../../bin/webkit_server", __FILE__)
|
||||
|
||||
read_pipe, write_pipe = IO.pipe
|
||||
@pid = fork do
|
||||
$stdout.reopen write_pipe
|
||||
read_pipe.close
|
||||
exec(server_path)
|
||||
end
|
||||
pipe = IO.popen(server_path)
|
||||
@pid = pipe.pid
|
||||
|
||||
at_exit { Process.kill("INT", @pid) }
|
||||
|
||||
write_pipe.close
|
||||
[read_pipe, write_pipe]
|
||||
pipe
|
||||
end
|
||||
|
||||
def discover_server_port(read_pipe)
|
||||
|
|
Loading…
Reference in a new issue