Fix signal handling behavior on Ruby 1.8.

This commit is contained in:
Hongli Lai (Phusion) 2011-08-22 09:32:08 +02:00
parent fe13b0b985
commit 3b025e7115
2 changed files with 25 additions and 1 deletions

View File

@ -118,7 +118,7 @@ class Capybara::Driver::Webkit
end
def forward_stdout(pipe)
while !pipe.eof?
while pipe_readable?(pipe)
line = pipe.readline
if @stdout
@stdout.write(line)
@ -128,6 +128,20 @@ class Capybara::Driver::Webkit
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 File

@ -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");