lua-users home
lua-l archive

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


On Wed, 2007-04-18 at 15:19 -0300, Roberto Ierusalimschy wrote:
> > Reading between the lines, the standard is pretty clear that
> > continuing to operate on a FILE after calling fclose() is not
> > valid. Effectively, continued use of a FILE* after calling
> > fclose() is similar to continued use a malloc()ed pointer after
> > calling free(). You might get lucky, but that doesn't make it valid.
> 
> That is true. Perhaps the best solution to all these problems would be
> to prohibit Lua from closing a standard file (stdin/stdout/stderr).
> Older versions of Lua had this restriction, I cannot remember why
> we lifted it.

Closing, or at least re-opening to /dev/null or similar, the standard
file handles is essential if you're writing a daemon that chroots and
drops privileges, otherwise you had FDs open as root.

B.