Skip to content

Commit

Permalink
Use Process.spawn to spawn webkit_server whenever possible.
Browse files Browse the repository at this point in the history
This allows one to close all unnecessary file descriptors in the child
process so they don't conflict with whatever the app is expecting.
It solves some problems with DRb.
  • Loading branch information
FooBarWidget committed Aug 17, 2011
1 parent dc49e5f commit 922d197
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/capybara/driver/webkit/browser.rb
Expand Up @@ -93,10 +93,18 @@ 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)
if Process.respond_to?(:spawn)
@pid = Process.spawn(server_path,
:in => :in,
:out => write_pipe,
:err => :err,
:close_others => true)
else
@pid = fork do
$stdout.reopen write_pipe
read_pipe.close
exec(server_path)
end
end
at_exit { Process.kill("INT", @pid) }

Expand Down

0 comments on commit 922d197

Please sign in to comment.