lua-users home
lua-l archive

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

On Tue, Oct 13, 2015 at 3:20 AM, Thierry FOURNIER <> wrote:
> I called functions executed in a coroutine. Maybe the developper copy
> the object containig the FD in the global env, or maybe not. It cant
> know this information, so I can't close himself the fd. Only the gc and
> the refcount system (I guess) know the information.

there's no refcount system in Lua.

but you can implement one: on your object initialization you can
register all 'open' objets in a global table, and another table where
you keep those that should stay open.  periodically (or at the pcall()
exit)  close any object that is still in the 'all objects' table and
not in the 'currently needed' table.