I am running code from the book programming in Lua... http://www.lua.org/pil/3.6.html
when I run this code in the terminal interpreter... it continues reading input forever...
list = nil
for line in io.lines() do
list = {next=list, value=line}
end
Ctrl C returns me to the prompt/bash. Is there another command to break? How do I break/return from a chunk of lua code without exiting the interpreter?
By pressing Ctrl-C in a Unix-like system, you are sending your process the signal of SIGINT
, which by default will terminate the process.
Your program continues reading from input forever because it's blocking in the call of io.lines()
, which keeps reading from standard input. To interrupt it, send your terminal an EOF
, this is done by pressing Ctrl-D in a Unix-like system.
On Windows, the key to send EOF
is Ctrl-Z.
You can indicate the end of input for stdin by using either Ctrl-Z or Ctrl-D.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With