I'm trying to get a program that allows for a program where I can have a stream with the user and run multiple ruby scripts, all of them printing to the same IO, and any input to the IO being sent to all programs. Here is a simple example.

Code:
 
      # app.rb is supposed to write user input to child which should echo it
      # which should print it to the user.
      # something like writing to echo and returning the return of echo.
       
      #child.rb
      while a = gets
        puts a
      end

      # app.rb
      child = IO.popen("ruby child.rb", "w+")
 
      get = Thread.new {
        loop {
          puts child.gets
        }
      }.join
      put = Thread.new {
        while x = gets
          child.puts x
          child.flush
        end
      }.join
I can get this working with Ports, but when I try and pipe it just doesn't work.(I've also tried having the programs all write to a named port, but that doesn't seem to work too well either) I think my lack of knowledge of Threads and Pipes is at fault here. Any help is appreciated. Pretty much what the script _should_ do is echo back anything the user types in.