lua-users home
lua-l archive

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

> Try this snippet (you'll probably have to adapt it, as it's verbatim
> from one of my libraries):
> void initIO(lua_State * L) {
> luaL_register(L,"io",IO_calltable);
> lua_getfield(L,-1,"stderr");
> lua_getfield(L,-2,"pipe");
> lua_getfenv(L,-2);
> lua_setfenv(L,-2);
> lua_pop(L,3);
> }
> Basically you have to connect the handles created by a pipe call with
> the correct close() function... and that is what the code above does: it
> takes stderr's environment and copies that to pipe()'s.
> (My C function that creates the pipes is unsurprisingly called pipe()).

Ahh thanks, Yeah now I understand how it gets the close function.
I'll just make my own and register it, sounds the easiest way.

I'll probably release my lib sometime soon, it might help some people :)