lua-users home
lua-l archive

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

> What's the latest on this?
> suggests that
> lua_sethook is not, in fact, signal safe, contrary to the assertion in
> the source (which also mentions "asynchronous use"). The manual makes
> no guarantee at all.
> I use lua_sethook in luaposix inside a signal handler, in order to
> implement Lua signal handlers. Is there a safer way to achieve this?

As that message says, sethook is not "theoretically" safe. However, the
only problem seems to be the non-atomicity of pointer accesses. So,
it should be safe given the extra condition that read/write of pointer
addresses are atomic (which I believe is true on most machines).

(The problem is that, while reading the hook address, a signal
may change that adrress. Without  atomicity, the read may result
in a value that is neither the original nor the new value.)

I would say that, for practical purposes, the function is safe,
but no standard ensures that.

-- Roberto