[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Closing the Lua state before exiting
- From: Coda Highland <chighland@...>
- Date: Sun, 8 Feb 2015 22:42:40 -0800
On Sun, Feb 8, 2015 at 10:37 PM, Dirk Laurie <firstname.lastname@example.org> wrote:
> 2015-02-09 7:59 GMT+02:00 Daurnimator <email@example.com>:
>> On 9 February 2015 at 00:53, Dirk Laurie <firstname.lastname@example.org> wrote:
>>> The manual for `os.exit` states:
>>> If the optional second argument close is true, closes the Lua state before
>>> 1. Why would one want to do this?
>> To ensure all resources are cleaned up correctly.
>> This may mean cleaning closing connections to servers, etc.
>>> 2. Why would one not want to to do this every time?
>> If you know there are no resources to be cleaned up and want to exit fast.
> Would it then not be a good habit to wrap os.exit so that the Lua state
> is closed in the case of normal termination unless explicitly specified
> otherwise? I..e. `close` defaults to `code`?
I think the "default" use of os.exit is a hard abort when the
application has entered an unrecoverable state and needs to bail out
as quickly as possible. Using something as brute-force as os.exit and
still wanting to run the cleanup is faintly smelly.