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]


2010年4月12日 steve donovan <steve.j.donovan@gmail.com>:
> This is ultimately not a Lua-specific problem, but here we go:
> sometimes you need an interactive Lua program that doesn't quietly die
> on control-C.
>
> I've tried using SetConsoleCtrlHandler(nil,1) and
> signal(SIGINT,SIG_IGN) using Alien, and no go.
>
> Obviously I could change lua.c to get the behaviour I need, but
> naturally I would prefer not to.
What you can do is simply use pcall, and check that the error message
is "interrupted!".

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