lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi

On Mon, Oct 08, 2007 at 04:58:14PM +0200, Michal Kolodziejczyk wrote:
> I can see that popen() can be used either to read or to write data
> from/to the process. Is there any hope it would be able to read and
> write data at the same time?
with a lua popen based on libc's popen: no

> How do you use lua when trying do write and read to/from the same
> process? (under linux if this matters)
you have to roll your own popen, based on a socketpair(PF_UNIX),
which is basically a bidirectional pipe.

You may try to attach your end to a FILE* using fdopen,
but I'm not sure whether glibc's stdio handles bidirectional
streams correctly (they need two separate buffers).

(I am using my homegrown stdio replacement anyway,
so I can for example also use TCP sockets with all
of Lua's IO calls.)


regards