lua-users home
lua-l archive

Re: Trapping Control-C in an interactive Lua program

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Apr 12, 2010 at 2:02 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> The final solution is a little ... bizarre.
Well, this is not the final/perfect solution, but it is simpler:
ensure that signal(2,1) is first called, then this will do the job:
		local res = io.read()
		if not res then
			print 'ctrl-c caught'
			return ''
		end
where signal() is declared like this
require 'alien'
local lib = alien.load 'msvcrt.dll' -- or alien.default for Unix
signal = lib.signal
signal:types{ret='int','int','int'}
steve d.

AltStyle によって変換されたページ (->オリジナル) /