lua-users home
lua-l archive

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


On Tue, Jun 9, 2015 at 2:55 PM, Mike <lua-l@inbox.ru> wrote:
> Hello, everybody.
>
> Is there a way to run a piece of code from the currently executing lua script
> (I mean a lua chunk or a function) in a "subprocess" and establish a pipe
> to/from its stdin/stdout something like io.popen() does?
>
> This is somewhat different from the launching a subprocess for an external
> program or for the lua script itself that may be done with io.popen()
> as the launched chunk is to be able to access the current values of the
> currently executing lua script global variables and/or upvalues
> (at least their copies in the forked process's image).
> More simply, I mean the feature like "process substitution" in bash,
> for example:
> -----
> #! /bin/bash
>
> greeting="Hello world!"
>
> do-greeting()
> {
>   echo "$greeting"
> }
>
> cat < <(do-greeting)
> -----
>
> Thanks.
>
> --
> Mike
>

The way you describe it, the answer is no.

However, the effect of what you're describing is essentially
threading, so I suggest that you check out Lanes and see if it offers
the tools you need to solve your problem.

/s/ Adam