[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Small question about os.exit and __gc
- From: Coroutines <coroutines@...>
- Date: Fri, 14 Mar 2014 06:39:45 -0700
On Fri, Mar 14, 2014 at 6:31 AM, Rob Kendrick <firstname.lastname@example.org> wrote:
> On Fri, Mar 14, 2014 at 09:12:16AM -0400, Rena wrote:
>> I also find it pretty odd that os.exit() doesn't close the state by
>> default. That's just asking for cleanup handlers for objects to not get
>> called, leaving things like temporary files and database connections laying
> Except the OS will close any network connections that are open, and if
> you did your temporary file right, it will be ephemeral and will also
> vanish on exit.
> On older versions of Lua, you can of course just try to iterate _G and
> destroy everything (except the os table) before calling os.exit() if
> you're concerned. (Bonus points for doing the same to the registry.)
Responding to your reply and Luiz':
- I could wrap os.exit() but the wrapper would only be assigned over
the original os.exit() potentially after libraries that reference the
original os.exit() have been require'd in. That said I do agree with
the default-no-cleanup, 2nd parameter to os.exit().
- Other things to consider that might get left around after process
cleanup/exit would be things like shared memory segments.
Okay I'm done, was just interested in this post :-)