lua-users home
lua-l archive

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



> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Edgar Toernig
> Sent: Monday, November 19, 2001 6:21 PM
> To: Multiple recipients of list
> Subject: Re: customizable Lua "panic" behavior
>
>
> Well, then say how you want to deal with it!  You _have_ to set up some
> wrapper that catches the error and (at least) restores the C stack!

I want to be able to call my own C function, that has the same properties as
exit (cleans up, handles the error) but does not have the nasty side-effect
of exiting my process. I'm imagining something like this:

int defaultExitImpl( lua_State * L )
{
  exit( 1 );
}

... during lua_open ..
L->exitFunc = defaultExitImpl
...

Now, we add a function like lua_setexithandler( lua_State *, lua_Cfunction )
to which I can pass my own exit handler. Let's imagine this was stored as
part of lua_State as "exitFunc"

so now, where ldo.c currently calls exit() it can now call

(*L->exitFunc)(L);

instead.

Does that make sense?

Eric