[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [RFC] fixing dup() in luaposix
- From: Natanael Copa <natanael.copa@...>
- Date: Mon, 28 Jan 2008 21:57:33 +0100
On Mon, 2008-01-28 at 12:57 -0700, Mark Edgar wrote:
> On Jan 28, 2008 11:56 AM, Natanael Copa <natanael.copa@gmail.com> wrote:
> > Hi,
> >
> > I'm looking into fixing dup() in luaposix.
> >
> > The problem in the current implementation from lposix is that it only
> > deals with fd's, integers, not lua files. This means you can not really
> > use the value returned from dup(2)
>
> I haven't looked at luaposix (or lposix in a while) but it should have
> fileno() and fdopen() functions also.
Currently it does not. There was an attempt to add fileno() to the io
library[1]. I did my own fileno() in lposix but it was not really
conveniant.
r,w = pipe()
dup(posix.fileno(r), posix.fileno(io.stdin))
Using lua files (with the previously dup2() func) was alot more
friendly.
r, w = pipe()
dup(r, io.stdin)
No other function handles int fd's. Even pipe() return lua files. So I
thought it might be clean to continue that way.
>
> -Mark
[1] http://lua-users.org/lists/lua-l/2006-04/msg00213.html