[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua bug - loadfile gets stdin confused
- From: Sam Roberts <sroberts@...>
- Date: Wed, 18 Apr 2007 18:38:13 -0700
On Wed, Apr 18, 2007 at 09:18:31PM -0300, Roberto Ierusalimschy wrote:
> > IIRC, the reason the original poster was closing stdin not for daemonization,
> > but because on windows, keeping a file open can interfere with other processes
> > ability to read/write the file. So not allowing std* to be closed solves one
> > problem, but creates another.
> Yes, but the problems are different. The first one is a bug, the second
> one is a restriction. A buggy implementation is not a good solution to
> any problem.
Fair enough, but lua's standard libraries are already famously
restricted, is it possible to restrict them to the point that nothing
unexpected ever happens?
loadfile() -- load stdin
What exactly did the caller expect this code would do?
Maybe this is the kind of stuff that isn't up for being changed, but it
appears to me that one source of this issue is that luaL_loadfile()
appears to be forbidden from "knowing" about the existence of the io
library. Core and io are both using stdin, but they don't cooperate,
otherwise loadfile() would use io.stdin, and all would be well again.
If instead of directly referencing stdin/stdout, luaL_loadfile() and
luaB_print() did so using an indirect mechanism which allowed the io
library to reset those pointers, things might be better.