lua-users home
lua-l archive

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

----- Original Message -----
From: <>; "Stratos" <>
To: "Multiple recipients of list" <>
Sent: Tuesday, August 20, 2002 12:39 PM
Subject: Re: Breaking infinite loops / stopping code execution from C

] ... SNIP ... [

> This can't be sufficient, as lua_error() will call exit() and the
> application will immediately terminate.
> Setting a hook may be a solution to break infinite loops, but is neither a
> good solution, as neither a counting hook nor a timer-based approach are
> very flexible. But the main problem is, the script
> MUST provide a way to stop execution on demand from the user, i.e. if
> he/she clicks a button, which
> won't be solved by setting a timer. Terminating the whole application
> doesn't seem to be good practice, either. So still, the problem

lua_error() doesn't appear to call exit() to me; however, lua_error()
can be easily replaced using lua_register().  You can define your
own custom error handler this way.  This allows you to redirect the
output to say, a window, instaead of stderr.

Here's how you can replace it using lua_register():
lua_register(L, LUA_ERRORMESSAGE, lua_myerror);

Hope this helps,
Kelmar K. Firesun (IRL: Bryce Simonds)