Created
August 7, 2013 18:54
-
-
Save gsamokovarov/6177264 to your computer and use it in GitHub Desktop.
PTY.spawn attaches a psuedo-terminal device to the standard input.
This file contains hidden or 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
require 'pty' | |
PTY.spawn 'irb' do |output, input, pid| | |
loop do sleep 1 | |
input.puts 'puts :Wootz!' | |
puts output.gets | |
end | |
end | |
__END__ | |
irb(main):001:0> puts :Wootz! | |
Wootz! | |
=> nil | |
irb(main):002:0> puts :Wootz! | |
Wootz! | |
=> nil | |
irb(main):003:0> puts :Wootz! | |
Wootz! | |
^Cconsole.rb:4:in `sleep': Interrupt | |
from console.rb:4:in `block (2 levels) in <main>' | |
from console.rb:4:in `loop' | |
from console.rb:4:in `block in <main>' | |
from console.rb:3:in `spawn' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment