lua-users home
lua-l archive

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


On Thu, Dec 27, 2012 at 3:30 PM, Bernd Eggink <monoped@sudrala.de> wrote:
> On 27.12.2012 23:55, Sam Roberts wrote:
>> On Thu, Dec 27, 2012 at 3:23 AM, Bernd Eggink <monoped@sudrala.de> wrote:
>>> Here the signal handling works, but the output is:
>>>
>>> Got signal      10
>>> nil     Interrupted system call 4
>> You say "but", isn't this the output you would expect?
> The expected output is "Got signal 10". I didn't expect the second line.

Reception of the signal will interrupt the system call. Keep in mind
when the handler runs, it effectively sets a global var and returns,
it doesn't run any lua code.

Only when lua vm is running again will it notice the var, then call
your so-called "lua signal handler".

In order for lua to run again, if it is currently blocked in a system
call, the sys call has to be interrupted.

It looks to me you are observing various race conditions around the
exact state lua is in when the sighandler runs (not your signal
handler, the one in the posix signal library that is setting the global var).