[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua calling exit()
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 20 Aug 2001 22:53:55 -0300
>(entire app exiting with no warning).
exit() is only called in luaD_breakrun. If there's no warning it's because
_ERRORMESSAGE is not displaying it. (You said you've redefined it.)
But you'd only get "unable to recover; exiting", which is hardly helpful...
>- What are some best practices for stack control?
One simple rule: never leave garbage on the stack. In other words, unless
you're returning values to Lua, leave the stack as you found it.
>- Do I have to extensively and manually check before every stack
>operation to make sure I never pop an empty stack (causes protection
>faults later on) or allow the stack to leak (eventually causes exit() on
>the entire app)?
You could try setting up call hooks and testing the stack only in these.
>- Is there a recommended way to completely prevent lua from ever calling
>exit, or at least call my exit handler so I can let people know what's
Simply define a Lua C function that does your main work and then lua_call it,
instead of calling it as you'd normally do in C:
If something goes wrong, error will be called normally.