[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Right way to emty stdin?
- From: Michal Kolodziejczyk <miko@...>
- Date: Wed, 23 Feb 2011 14:02:25 +0100
On 23.02.2011 13:48, Gilles Ganault wrote:
> Any idea what could be wrong with the code?
There is nothing wrong with the code. Works for me as expected:
lua myscript.lua < /dev/null
io.read() by default reads whole line ('*l'). So you need to send it a
line (ending with CR/LF, or CTRL+D for empty line), or close the input.
Otherwise it waits in blocking read. You seem to expect it is
non-blocking. Try io.read(0) and read the manual:
http://www.lua.org/manual/5.1/manual.html#pdf-file:read
Regards,
miko