lua-users home
lua-l archive

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


On Mon, Apr 12, 2010 at 7:24 PM, Patrick Donnelly <batrick@batbytes.com> wrote:
>> Also, you can put a userdata in the registry, and hook __gc to find
>> out when the global state
>> is destroyed.
>
> I don't see how that helps.

It allows you to notice when the lua_State is destroyed. Probably you
don't care to handle that case.

> I tried to not have the library make any assumptions about behavior
> (e.g., changing to default after signal receipt until hook runs). The
> library right now replaces the SIGINT handler of the interpreter
> because it needs a hook for all Lua threads. If you desire the
> application to close then use Ctrl+\ for SIGQUIT?

As soon as someone does require"signal", you replace the lua command
line interpreter's SIGINT with a new one that has noticeably different
behaviour. I'm just pointing it out, if that's your intention, that's
cool.

>> But, did I miss it? Is it possible to set the sig handler to SIG_IGN
>> or SIG_DFL? I just saw a way to set it
>> back to it's "original" behaviour.
>
> signal("SIGINT", nil) --> default SIGINT

Missed that, thanks.

> signal("SIGINT", function() end) --> ignore SIGINT

Having a signal handler is not the same as having a signal handler be ignored.

It isn't the same in the sense of system call restart behaviour, and
it is absolutely not the same for SIGCHLD, check the man pages for
wait(2):

http://swoolley.org/man.cgi/2/wait

> POSIX.1 allows for a signal to be delivered more than once when a
> process unblocks a signal. Intuitively, we go into a blocked state
> whenever we are running Lua code but periodically check via a hook for
> signals.

I think I'm missing something. It sounds like you are saying you block
signals, and then check for them only when the interpreter is running.
Would that not mean that they are never delivered at all if the
interpreter is blocked in a system call?  So, for example, lua process
blocked reading from stdin, or a tcp server using luasocket and
blocked on accept would never receive a signal until it receives a new
client connection?

Cheers,
Sam