lua-users home
lua-l archive

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


On Sun, Mar 25, 2012 at 16:02, Petite Abeille <petite.abeille@gmail.com> wrote:
> Hello,
>
> Trying to use LHF's lalarm [1] library to simulate a little timer of sort.
>
> All good except when used in conjunction with io:read(), in which case the alarm is not triggered until after the read completes.
>
> Is that how it's meant to be? E.g. read() is blocking everything and hoping for an alert is wishful thinking? Or am I missing something?

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

And I can't see anything that could be done with that... :-( (Aside of
throwing out io:read() and using something non-blocking instead. Maybe
lua-ev?)

Alexander.