Created
February 5, 2013 09:10
-
-
Save jonleighton/4713225 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/spring/application.rb b/lib/spring/application.rb | |
index 6e241a8..614f5f5 100644 | |
--- a/lib/spring/application.rb | |
+++ b/lib/spring/application.rb | |
@@ -62,6 +62,8 @@ module Spring | |
def serve(client) | |
redirect_output(client) do | |
+ stdin = client.gets.chomp | |
+ | |
args_length = client.gets.to_i | |
args = args_length.times.map { client.read(client.gets.to_i) } | |
command = Spring.command(args.shift) | |
@@ -72,6 +74,18 @@ module Spring | |
ActionDispatch::Reloader.prepare! | |
pid = fork { | |
+ # Open a new session so we can set the controlling terminal | |
+ Process.setsid | |
+ | |
+ # Open the terminal, on Linux this automatically becomes the CTTY | |
+ STDIN.reopen(stdin, "r") | |
+ | |
+ # On OS X (BSD) we have to issue an ioctl(fd, TIOCSCTTY) in order | |
+ # to set the CTTY. However I don't know of a way to get this | |
+ # constant by name without a C extension. So at the moment we're | |
+ # hardcoding the value and hoping for the best. | |
+ STDIN.ioctl(0x540E) | |
+ | |
IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") } | |
command.call(args) | |
} | |
@@ -103,13 +117,13 @@ module Spring | |
def redirect_output(socket) | |
STDOUT.reopen socket.recv_io | |
STDERR.reopen socket.recv_io | |
- STDIN.reopen socket.recv_io | |
+ # STDIN.reopen socket.recv_io | |
yield | |
ensure | |
STDOUT.reopen @stdout | |
STDERR.reopen @stderr | |
- STDIN.reopen @stdin | |
+ # STDIN.reopen @stdin | |
end | |
end | |
end | |
diff --git a/lib/spring/client/run.rb b/lib/spring/client/run.rb | |
index b3ee0ac..15bc114 100644 | |
--- a/lib/spring/client/run.rb | |
+++ b/lib/spring/client/run.rb | |
@@ -30,7 +30,8 @@ module Spring | |
application.send_io STDOUT | |
application.send_io STDERR | |
- application.send_io stdin_slave | |
+ # application.send_io STDIN | |
+ application.puts stdin_slave.path | |
application.puts args.length | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment