Permalink
Browse files

Use Process.spawn to spawn webkit_server whenever possible.

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...
1 parent dc49e5f commit 922d197adfe5bb636f381ecae250744c3e8475cc @FooBarWidget FooBarWidget committed Aug 17, 2011
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/capybara/driver/webkit/browser.rb
@@ -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) }

0 comments on commit 922d197

Please sign in to comment.