2006/6/1, Pedro Cộte-Real <pedrocr / gmail.com>:
> On 5/31/06, Logan Capaldo <logancapaldo / gmail.com> wrote:
> > I'm not sure _exactly_ what the problem is, but I imagine that
> >   io.write mytext
> >   io.close_write # let the process know you've given it all the data
> >   result = io.read
> >
> > will fix things right up.
>
> Yes, this works. The problem with this is that since I only read after
> I write the whole thing the process might block since noone is reading
> from it and not write anything. Is there some way I can connect the io
> object I get from popen to another io object I create myself. So as to
> create an actual pipe in ruby?

I suspect the error was caused because the process had terminated already:

>> IO.popen("ls", "r+") {|io| sleep 5; io.write "test"}
Errno::EPIPE: Broken pipe
        from (irb):1:in `write'
        from (irb):1
        from (irb):1
        from :0

Does the process you start maybe not read its stdio?  Or stop reading
after some time has passed without input?  Where exactly do you get
the exception?  Is it during read or write?

If you need to read and write interleavingly then I suggest you use a
second thread.

Regards

robert


-- 
Have a look: http://www.flickr.com/photos/fussel-foto/