[Tarantool-patches] [PATCH 1/5] popen: Introduce a backend engine

Cyrill Gorcunov gorcunov at gmail.com
Sat Nov 30 13:47:34 MSK 2019


On Sat, Nov 30, 2019 at 01:04:45PM +0300, Konstantin Osipov wrote:
> 
> Could you provide a Lua example usage of popen() which would lead 
> to the situation you describe here?
> 
> Seems like in order for that to happen the Lua script has to
> provide both input and output streams to the called program, and
> in this case the script should not expect that there is any
> ordering in which the input is consumed and the output is
> produced.
> 
> In any case discussing this problem would be easier if there is an
> example.

An example is in one of my patch, here is it (result file)
---

--
-- Test for stdin/out stream
--
script="prompt=''; read -n 5 prompt; echo -n $prompt"
 | ---
 | ...
popen = fio.popen(script, "rw")
 | ---
 | ...
popen:write("input")
 | ---
 | - 5
 | ...
popen:read()
 | ---
 | - input
 | ...
popen:close()
 | ---
 | - true
 | - null
 | ...

The main thing is that as far as I remember "real" stdin/out/err are
the unix pty terminals, and they are in blocking mode. IOW if you
run

 $ sh -c "prompt=''; read -n 5 prompt; echo -n $prompt"

inside real shell the read will be blocked until you enter data
to stdin. And I think users of popen will expect the same behaviour.
Anyway, Kostya, I'll investigate python behaviour more on the weekend
to get in with more details.


More information about the Tarantool-patches mailing list