Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C3E7C433EF for ; Fri, 17 Dec 2021 17:49:50 +0000 (UTC) Received: from shymkent.ilbers.de (shymkent.ilbers.de [85.214.156.166]) by mx.groups.io with SMTP id smtpd.web08.9305.1639763388791009546 for ; Fri, 17 Dec 2021 09:49:49 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: ilbers.de, ip: 85.214.156.166, mailfrom: amikan@ilbers.de) Received: from [192.168.67.164] (mm-214-81-214-37.mgts.dynamic.pppoe.byfly.by [37.214.81.214] (may be forged)) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8) with ESMTPSA id 1BHHnfgS019499 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Dec 2021 18:49:44 +0100 Subject: Re: [bitbake-devel] [PATCH] process: Do not mix stderr with stdout To: Alexander Kanavin Cc: Baurzhan Ismagulov , bitbake-devel@lists.openembedded.org References: <16BED60D9AF8ECE2.12270@lists.openembedded.org> From: Anton Mikanovich Message-ID: Date: Fri, 17 Dec 2021 20:49:35 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------D43DB6D8E87A20F4126FE58E" Content-Language: en-US List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 17 Dec 2021 17:49:50 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/13193 This is a multi-part message in MIME format. --------------D43DB6D8E87A20F4126FE58E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by shymkent.ilbers.de id 1BHHnfgS019499 17.12.2021 19:54, Alexander Kanavin wrote: > It helps if you describe the problem that occurs without the patch and=20 > how it can be observed. > > Ale > > On Fri 17. Dec 2021 at 19.43, Anton Mikanovich > wrote: > > 08.12.2021 19:57, Anton Mikanovich wrote: > > We should not redirect stderr to stdout if we need to get separat= ed > > stdout and stderr contents from Popen.communicate() later. > > > > Signed-off-by: Anton Mikanovich > > > --- > >=C2=A0 =C2=A0lib/bb/process.py | 2 +- > >=C2=A0 =C2=A01 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/bb/process.py b/lib/bb/process.py > > index d5a1775f..af5d804a 100644 > > --- a/lib/bb/process.py > > +++ b/lib/bb/process.py > > @@ -60,7 +60,7 @@ class Popen(subprocess.Popen): > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"close_fds": True, > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"preexec_fn": subprocess_= setup, > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"stdout": subprocess.PIPE= , > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 "stderr": subprocess.STDOUT, > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 "stderr": subprocess.PIPE, > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"stdin": subprocess.PIPE, > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"shell": False, > >=C2=A0 =C2=A0 =C2=A0 =C2=A0} > > Can anyone review this change to proof the fix is correct? > > --=20 > Anton Mikanovich > Promwad Ltd. > External service provider of ilbers GmbH > Maria-Merian-Str. 8 > 85521 Ottobrunn, Germany > +49 (89) 122 67 24-0 > Commercial register Munich, HRB 214197 > General Manager: Baurzhan Ismagulov > > > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- > Links: You receive all messages sent to this group. > View/Reply Online (#13190): > https://lists.openembedded.org/g/bitbake-devel/message/13190 > > Mute This Topic: > https://lists.openembedded.org/mt/87592650/1686489 > > Group Owner: bitbake-devel+owner@lists.openembedded.org > > Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub > > [alex.kanavin@gmail.com ] > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- > Hello, Alexander As I've already mentioned in description the problem is mixing both=20 stderr and stdout of the command to stdout output variable when using=20 bb.process.run() Here are minimal steps to reproduce: $ cat /usr/bin/test.sh #!/bin/sh echo "This is stderr" >&2 echo "This is stdout" Task: python do_test() { =C2=A0=C2=A0=C2=A0 out,err =3D bb.process.run('test.sh') =C2=A0=C2=A0=C2=A0 bb.warn('STDOUT:', out or 'EMPTY') =C2=A0=C2=A0=C2=A0 bb.warn('STDERR:', err or 'EMPTY') } addtask do_test Result without the patch: WARNING: do_test: STDOUT:This is stderr This is stdout WARNING: do_test: STDERR:EMPTY So both stdout and stderr of test.sh were filled to out variable. Result after the patch: WARNING: do_test: STDOUT:This is stdout WARNING: do_test: STDERR:This is stderr --=20 Anton Mikanovich Promwad Ltd. External service provider of ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn, Germany +49 (89) 122 67 24-0 Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov --------------D43DB6D8E87A20F4126FE58E Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by shymkent.ilbers.de id 1BHHnfgS019499 17.12.2021 19:54, Alexander Kanavin wrote:
It helps if you describe the problem that occurs without the patch and how it can be observed.

Ale=C2=A0

On Fri 17. Dec 2021 at 19.43, Anton Mikanovich <a= mikan@ilbers.de> wrote:
08.12.2021 19:57, Anton Mikanovich wrote:
> We should not redirect stderr to stdout if we need to get separated
> stdout and stderr contents from Popen.communicate() later.
>
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>=C2=A0 =C2=A0lib/bb/process.py | 2 +-
>=C2=A0 =C2=A01 file changed, 1 insertion(+), 1 deletion(-= )
>
> diff --git a/lib/bb/process.py b/lib/bb/process.py
> index d5a1775f..af5d804a 100644
> --- a/lib/bb/process.py
> +++ b/lib/bb/process.py
> @@ -60,7 +60,7 @@ class Popen(subprocess.Popen):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"close_fds": Tru= e,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"preexec_fn": su= bprocess_setup,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"stdout": subpro= cess.PIPE,
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 "stderr": subprocess.STDOUT= ,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 "stderr": subprocess.PIPE,<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"stdin": subproc= ess.PIPE,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"shell": False,<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0}

Can anyone review this change to proof the fix is correct?
--
Anton Mikanovich
Promwad Ltd.
External service provider of ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn, Germany
+49 (89) 122 67 24-0
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov


-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-
Links: You receive all messages sent to this group.
View/Reply Online (#13190): https://lists.openembedded.org/g/bitbake-devel/message/13190
Mute This Topic: https://lists.openembedded.org/mt/87592650/1686489
Group Owner: bitbake-devel+ow= ner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alex.kanavin@gmail.com]
-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-

Hello, Alexander

As I've already mentioned in description the problem is mixing both stderr and stdout of the command to stdout output variable when using bb.process.run()
Here are minimal steps to reproduce:

$ cat /usr/bin/test.sh
#!/bin/sh
echo "This is stderr" >&2
echo "This is stdout"

Task:

python do_test() {
=C2=A0=C2=A0=C2=A0 out,err =3D bb.process.run('test.sh')
=C2=A0=C2=A0=C2=A0 bb.warn('STDOUT:', out or 'EMPTY')
=C2=A0=C2=A0=C2=A0 bb.warn('STDERR:', err or 'EMPTY')
}
addtask do_test

Result without the patch:

WARNING: do_test: STDOUT:This is stderr
This is stdout
WARNING: do_test: STDERR:EMPTY

So both stdout and stderr of test.sh were filled to out variable.
Result after the patch:

WARNING: do_test: STDOUT:This is stdout
WARNING: do_test: STDERR:This is stderr

--=20
Anton Mikanovich
Promwad Ltd.
External service provider of ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn, Germany
+49 (89) 122 67 24-0
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov
--------------D43DB6D8E87A20F4126FE58E--