lua-users home
lua-l archive

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


> (WinXP SP2, Lua 5.1.1)
> 
> [...]
> 
> The call to os.remove() fails, reporting the file is locked by
> someprocess. If I add call to collectgarbage("collect") on line (*),
> os.remove() succeeds. Looks like dofile() keeps file open until GC.
> 
> It is somewhat inconvenient. Is it a bug or intentional feature?

This is weird. dofile (which uses luaL_loadfile) always closes the file
after parsing it (unless the file is stdin). Moreover, I don't see how
a garbage collection would close the file. Unlike files created to
be used by Lua, e.g., by io.open, the file created by loadfile is only
a FILE*; it is not a userdata, and cannot have a finalizer.

-- Roberto