From: unbewusst Date: 2007-09-07T00:25:18+09:00 Subject: Re: returning a pipe ??? On 4 sep, 23:57, Paul Brannan wrote: > On Wed, Sep 05, 2007 at 02:35:10AM +0900, unbewusst wrote: > > then i wonder if there is a way somehow to return the > > "myCommunicationsPipe" above directly (more directly) from C to ruby. > > > something like IO.popen... > > I see at least two options: > > - Use the macros in rubyio.h to wrap the FILE* that you already have. > This is "cheating" the ruby API a bit, since you'd be accessing > structures that I don't think Matz intended for us to access > directly. > > - Use IO#fdopen to re-open the pipe once it is opened. > > Paul Luc Heinriwh gave me yesterday a third solution perfectly working, from C ext to Ruby side i return : INT2FIX( fileno(myPipe)) and on ruby side i can use it as a standard IO pipe... that's all very simple and efficient ;-)