Created
February 4, 2013 23:29
-
-
Save jonleighton/4710718 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..2e60965 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.recv_io | |
+ | |
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) | |
+ | |
+ # 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..0c06684 100644 | |
--- a/lib/spring/client/run.rb | |
+++ b/lib/spring/client/run.rb | |
@@ -30,6 +30,7 @@ module Spring | |
application.send_io STDOUT | |
application.send_io STDERR | |
+ # application.send_io STDIN | |
application.send_io stdin_slave | |
application.puts args.length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment