lua-users home
lua-l archive

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

On Mon, Feb 21, 2011 at 11:06 AM, Tony Finch <> wrote:
> On Mon, 21 Feb 2011, Sam Roberts wrote:
>> On Fri, Feb 18, 2011 at 3:04 AM, Tony Finch <> wrote:
>> > I note that if the reader function is a simple wrapper around the read(2)
>> > syscall then it is possible for it to return EOF then on a subsequent call
>> > return some data, e.g. if the input is a terminal.
>> read() should block on read from a terminal -- or if the fd is set
>> non-blocking, return -1.
>> read() will return zero on EOF, and then return some positive value if
>> more is written to the end of file, but that's pretty pathological.
> Try running the following program. Type stuff at it and see what happens
> when you press CTRL-D before or after typing a newline.

That's funny, I wrote basically the same code :-)

If you use ctrl-D to signal end-of-file, shouldn't the reader stop reading?

Surely you aren't suggesting that when someone types ctrl-D at a
terminal to indicate end of
file, and lua_Reader() returns zero, that there is a problem with that?