lua-users home
lua-l archive

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


Hello,

I've written a little wrapper to use SDL from within Lua scripts. When I use SDL with C, I usually call atexit(SDL_Quit) after I initialized it. I have to call SDL_Quit on exit, because bad things could happen if I don't. However, since I initialize SDL in Lua, I have to make sure SDL_Quit (i.e. my wrapper function for it) gets called whenever the chunk execution ends. If there is an error in my script and it aborts, the program terminates without calling SDL_Quit. Is there some kind of "atexit" function for Lua? I have looked at hooks, but they don't seem to be made for this purpose. Unfortunately it is not an option to check if SDL_Quit has to be called by the interpreter after the script execution has ended.

Regards,
Bernhard