Permalink
Browse files

Fix signal handling behavior on Ruby 1.8.

  • Loading branch information...
1 parent fe13b0b commit 3b025e7115c8f9688e83df47937f53c5ed029e18 @FooBarWidget FooBarWidget committed Aug 22, 2011
Showing with 25 additions and 1 deletion.
  1. +15 −1 lib/capybara/driver/webkit/browser.rb
  2. +10 −0 src/main.cpp
@@ -118,7 +118,7 @@ def discover_server_port(read_pipe)
end
def forward_stdout(pipe)
- while !pipe.eof?
+ while pipe_readable?(pipe)
line = pipe.readline
if @stdout
@stdout.write(line)
@@ -128,6 +128,20 @@ def forward_stdout(pipe)
rescue EOFError
end
+ if !defined?(RUBY_ENGINE) || (RUBY_ENGINE == "ruby" && RUBY_VERSION <= "1.8")
+ # please note the use of IO::select() here, as it is used specifically to
+ # preserve correct signal handling behavior in ruby 1.8.
+ # https://github.com/thibaudgg/rb-fsevent/commit/d1a868bf8dc72dbca102bedbadff76c7e6c2dc21
+ # https://github.com/thibaudgg/rb-fsevent/blob/1ca42b987596f350ee7b19d8f8210b7b6ae8766b/ext/fsevent/fsevent_watch.c#L171
+ def pipe_readable?(pipe)
+ IO.select([pipe])
+ end
+ else
+ def pipe_readable?(pipe)
+ !pipe.eof?
+ end
+ end
+
def connect
Capybara.timeout(5) do
attempt_connect
View
@@ -1,8 +1,18 @@
#include "Server.h"
#include <QtGui>
#include <iostream>
+#ifdef Q_OS_UNIX
+ #include <unistd.h>
+#endif
int main(int argc, char **argv) {
+#ifdef Q_OS_UNIX
+ if (setpgid(0, 0) < 0) {
+ std::cerr << "Unable to set new process group." << std::endl;
+ return 1;
+ }
+#endif
+
QApplication app(argc, argv);
app.setApplicationName("capybara-webkit");
app.setOrganizationName("thoughtbot, inc");

0 comments on commit 3b025e7

Please sign in to comment.