From: Kristof Bastiaensen Date: 2004-04-28T07:29:03+09:00 Subject: Re: popen issues On Wed, 28 Apr 2004 06:06:30 +0900, Hal Fulton wrote: > Here's something I've never figured out. > > Suppose I want real two-way communication with a process via popen. > This seems doable. > > But apparently the read hangs until I do a close_write; and if I > do that, I can't write again. A flush doesn't work. > Hi, I don't know how to do it in pure Ruby, but if you are using a GUI (Gtk) it is fairly easy. pipe = IO.popen("prog", "w+") Gtk::input_add(pipe.to_i, Gdk::INPUT_READ) { str = pipe.gets puts "got " + str } This will work only from the event-dispatch routine inside Gtk.main(). Kristof