lua-users home
lua-l archive

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


On Sun, Sep 6, 2009 at 3:46 PM, Matthew Paul Del Buono<delbu9c1@erau.edu> wrote:
>>If a Lua script wants to exit
>>cleanly, it should return from its main chunk. If it wants to
> exit
>>quickly, it should call os.exit().
>
> Unfortunately, this is not always a suitable situation. For
> example, one place where I use Lua scripts a lot is in SVN post-
> commit hooks where I need the ability to have the Lua
> interpreter return a non-zero status code. I use os.exit() to do
> this; the only other way to get a non-zero status at exit would
> be to throw an uncaught error, which results in messages
> appearing client-side which looks like a server error instead of
> a user error.

A common way to deal with this is reopening stderr so it can go to a log file
and not pollute the interaction with the user through the svnserver.
Unfortunately, it doesn't appear
to be possible with lua's simple io library, or am I missing something
in the docs?

Anyhow, as has been pointed out, there _are_ no memory leaks with
os.exit(), the process
ceases to exist, thus has no memory (or open descriptors, sockets, etc.).

It might be useful for os.exit() to close the lua state, not to clean
up OS-managed
resources that will be released anyway, but for causing userdata to be
finalized by calling __gc.

Cheers,
Sam