lua-users home
lua-l archive

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



On Sat, Mar 17, 2012 at 10:01 AM, steve donovan <steve.j.donovan@gmail.com> wrote:
On Sat, Mar 17, 2012 at 10:39 AM, Flemming Madsen <lua@themadsens.dk> wrote:
> fdesc The posix file descriptor "small integer". Use the ":getfd()" method
> on a "normal" lua stream or socket to obtain fdesc.

I know that LuaSocket objects have a getfd() method, but regular Lua
file objects don't, unfortunately. The implementation of file objects
is not standardized, so having such a method would be rather useful.

steve d.


Yes, right. Can be fixed with luaposix though:

getmetatable(io.stdin).getfd = function(s) return posix.fileno(s) end

Alternatively a patch to the lua core. Here is one here

/Flemming