lua-users home
lua-l archive

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


On Tue, Apr 13, 2010 at 2:36 AM, Sam Roberts <vieuxtech@gmail.com> wrote:
>> 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.

I made a note of it (in caps) in the README.

>>> 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.

The README is a bit unclear I'll correct that.

>> 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

You're right. I'll add a method to ignore signals.

>> 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?

I never actually block the signals. I just keep track of the number of
received signals between hooks. The library can be perceived as
mimicking the behavior of POSIX (or something allowed by POSIX).

-- 
- Patrick Donnelly