Last active
February 15, 2018 02:41
-
-
Save andydna/644c2b63ec9c8ccbd533b6c31a340c55 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
# test/echo_loop.rb | |
loop do | |
puts $stdin.gets | |
end | |
# elsewhere | |
require 'open3' | |
# this works | |
stdin, stdout, stderr, wait_thr = Open3.popen3("dc") | |
loop do | |
stdin.puts "2 1 + p" | |
res = stdout.gets | |
puts res | |
sleep 1 | |
end | |
# this doesn't | |
stdin, stdout, stderr, waiter = Open3.popen3('ruby test/echo_loop.rb') | |
stdin.puts 'hello' | |
res = stdout.gets # hangs here. what am i missing/doing wrong? | |
# i want to stdin.puts "something" | |
# and stdout.gets "something" | |
# for testing shelling out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment