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?
-
Sorry for the Delay in saying thanks my brother broke my computer monitor. Ctrl D was the correct answer.Punkroku– Punkroku2018年10月10日 01:25:48 +00:00Commented Oct 10, 2018 at 1:25
3 Answers 3
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.
-
Thank you. Ctrl+D is what I was looking for. In Linux the Ctrl+Z returns to the prompt > ^Z [2]+ Stopped luaPunkroku– Punkroku2013年09月13日 01:07:24 +00:00Commented Sep 13, 2013 at 1:07
-
Back to this can you help me create a shellscript or virus or deamon that will spam ctrl+C to SIGINT preventing any programs from running in terminal without explicit permission or disabling of this type of virus protection. I am not trying to kill the current program or break from it but do that to other terminal programs.Punkroku– Punkroku2018年10月10日 01:21:13 +00:00Commented Oct 10, 2018 at 1:21
-
Thank you for that answer. PS i tried explaining the idea at tiny.cc/dfvp and github.com/punkroku/dfvpPunkroku– Punkroku2018年10月10日 01:22:25 +00:00Commented Oct 10, 2018 at 1:22
You can indicate the end of input for stdin by using either Ctrl-Z or Ctrl-D.
-
Have you heard of autokey I want to use it with linux and spam ctrl C to prevent viruses. Or better if a terminal app runs then hold CTRL C or send pausebreak to keyboard bufferPunkroku– Punkroku2018年10月10日 01:24:10 +00:00Commented Oct 10, 2018 at 1:24
CTRL-U
deletes all the characters before the cursor position, therefore the whole line. It also works like this in a Linux shell.