[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua and signals
- From: Sam Roberts <vieuxtech@...>
- Date: Wed, 26 Dec 2012 12:31:41 -0800
To the OP, you aren't multi-threaded, I hope?
Try running inside a debugger, then hitting it with the signal.
On Wed, Dec 26, 2012 at 11:19 AM, Owen Shepherd <owen.shepherd@e43.eu> wrote:
> 2. It calls lua_sethook from inside the signal handler. Where anybody gets
> the idea this is a clever thing to do, never mind the inkling that it might
> work when the documentation says nothing to that effect, I have no idea.
Probably from the lua source code:
http://www.lua.org/source/5.1/lua.c.html
lstop(), first function in that file.
IIRC, sethook can't be guaranteed sig-safe in an only-ANSI conformant
system, but it is in on most operating systems, but maybe only if word
size is >= 32? Searching the list archives should find comments on
this from Luis.
> Note that stdio and malloc are not signal safe. Handling signals
The actual call of the OP's lua "signal handling" function doesn't
occur in the signal handler, it occurs when the lua VM notices the
hook is set, so the OP's code isn't doing I/O "inside" a signal
handler.
> asynchronously from a non- native language is just not going to work
What's a native language? perl, ruby, even bash, all have signal handling.
> Iirc there are at least two specialized signal libraries. Have you tried
> them?
At least one of them (maybe both?) was originally a copy of the
approach from lua.c, that then got generalized.
Cheers,
Sam