lua-users home
lua-l archive

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


On Mar 25, 2012, at 2:10 PM, Alexander Gladysh wrote:

> This is common and painful problem for all code that deals with
> signals in Lua. Haven't seen lalarm implementation, but signal handler
> usually merely enables the Lua hook to fire on the next instruction
> (since you can't do much in a signal handler), the actual signal
> handler is run only after execution returns to the Lua VM (which
> wouldn't happen until io:read() finishes).

Thanks for the feedback. 

Just to check, I tried Jesse Luehrs' LuaSignal [1] instead of LHF's lalarm.

There is a  handy alarm_test.lua included which mimics LHF's lalarm behavior.

And… LuaSignal seems to handle io:read() differently, in the sense that it does interrupt read() and keeps going, e.g.:

$ lua alarm_test.lua 
hello
in alarm!	17:10:26	0	0%
io.stdin:read	nil	Interrupted system call	4
in alarm!	17:10:27	1	0%
io.stdin:read	nil	Interrupted system call	4
...

This looks more like the behavior I had in mind.

[1] https://github.com/doy/luasignal