lua-users home
lua-l archive

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

Hi Robert,

On Sun, Sep 6, 2009 at 8:37 PM, Robert G.
Jakabosky<> wrote:
> On Sunday 06, Luiz Henrique de Figueiredo wrote:
>> > In my opinion, os.exit() is for exiting quickly and letting the OS
>> > worry about cleaning up.
>> Exactly. Nevertheless, in Lua 5.2, os.exit will accept a flag that tells
>> whether to close the Lua state.
> How about an os.atexit(func) function to register Lua functions to called when
> os.exit() or a normal exit happens.  This way Lua scripts can still do
> resource cleanup if they need/want to.  Attached 'atexit.lua' is a simple
> pure Lua os.atexit() function, it catches both 'os.exit()' and normal exit.
> Personally I am in the camp of people that like to have all memory/resources
> released by the application/daemon before it exit's back to the OS.  But for
> simple shell type scripts this is overkill.
> P.S Yay for money-patching. ;)

Since this can be done in Lua (as you show), why does this need to be
supported in C?

-Patrick Donnelly

"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."

- Benjamin Franklin