[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Break out of program in interpreter
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 14 May 2013 11:15:53 -0300
> while true do os.execute('echo hello world') end
>
> cannot be stopped with ^C.
The ^C is caught by the forked process and is never seen by Lua. Try
while true do os.execute('echo hello ; sleep 5; echo bye') end
When you press ^C, you never see "bye".
Now try hitting ^C on this code:
while os.execute("echo hello") do end
If you print the return value, you'll see
true exit 0
hello
true exit 0
hello
true exit 0
^Cnil signal 2
Bottom line: test the return value of os.execute if you want to handle ^C
in forked processes.