lua-users home
lua-l archive

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

On Wed, 23 Feb 2011 08:34:51 -0500, David Favro <>
> will return an empty string when it encounters the blank line
>which indicates the end of the variable-list, rather than returning nil,
>which occurs when EOF is reached on input (i.e. the pipe from asterisk (AGI)
>or socket (FastAGI) is closed). 

Thanks for the explanation. I found that I must not only use the "line
== break" line, but also the "io.write()" right after it, or the loop
won't stop and the script will remain in RAM:

while true do
        local line =
        if line == "" then break end
        -- Without line below, script never ends
        io.write("NOOP ",line,"\n")

The documentation only says the script is expected to read all the
data sent to it through stdin, but it doesn't mention having to reply.

>You can implement almost any AGI script _without_ using non-blocking or
>asynchronous I/O, which I've always found require some C functions rather
>than lua's standard I/O library.

I'm fine with using synchronous I/O (I guess Lua's "io" object _is_
synchronous), since the tasks won't take much time anyway.

Thank you.