From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 7152B46970F for ; Sat, 30 Nov 2019 13:47:37 +0300 (MSK) Received: by mail-lf1-f68.google.com with SMTP id 203so24334435lfa.12 for ; Sat, 30 Nov 2019 02:47:37 -0800 (PST) Date: Sat, 30 Nov 2019 13:47:34 +0300 From: Cyrill Gorcunov Message-ID: <20191130104734.GR19879@uranus> References: <20191129094059.GA19879@uranus> <20191129111903.GA7760@atlas> <20191129113659.GE19879@uranus> <20191129145028.GA18043@atlas> <20191129151410.GJ19879@uranus> <20191129183144.GB16921@atlas> <20191129191708.GN19879@uranus> <20191130041405.GB31199@atlas> <20191130073628.GP19879@uranus> <20191130100445.GA16163@atlas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191130100445.GA16163@atlas> Subject: Re: [Tarantool-patches] [PATCH 1/5] popen: Introduce a backend engine List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Konstantin Osipov Cc: tml 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.