[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Break out of program in interpreter
- From: Jorge <xxopxe@...>
- Date: Tue, 14 May 2013 11:02:49 -0300
On 05/14/2013 10:31 AM, Jose Torre-Bueno wrote:
Yes that does work. However
while true do os.execute('echo hello world') end
cannot be stopped with ^C. The only way to end it is to kill the whole terminal session.
What is hapening isthat the ^C is caught by the shell running inside
os.exec(), so os.exec returns and the lua program loops again. You have
to either have a lot of luck so the ^C arrives while the control is in
lua code, or catch the return from os.exec and detect it was canceled.
For example, in Lua 5.1:
while true do
if os.execute('echo hello world') ~= 0 then return end