From: Paolo Bonzini Subject: Re: [kvm-unit-tests PATCH] scripts/arch-run: print stderr immediately Date: Thu, 3 Nov 2016 14:32:24 +0100 Message-ID: <5716fa76-02e6-d69b-ba24-8a937eb7bbb2@redhat.com> References: <20161102205029.880-1-rkrcmar@redhat.com> <20161102210548.vwzhlrrv7qd6vuba@kamzik.brq.redhat.com> <7f385e31-cf44-758d-9d81-5151823b5395@redhat.com> <20161103125332.GC7771@potion> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: Andrew Jones , kvm@vger.kernel.org To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Return-path: Received: from mail-wm0-f54.google.com ([74.125.82.54]:35632 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754343AbcKCNc2 (ORCPT ); Thu, 3 Nov 2016 09:32:28 -0400 Received: by mail-wm0-f54.google.com with SMTP id a197so205623436wmd.0 for ; Thu, 03 Nov 2016 06:32:27 -0700 (PDT) In-Reply-To: <20161103125332.GC7771@potion> Sender: kvm-owner@vger.kernel.org List-ID: On 03/11/2016 13:53, Radim Krčmář wrote: > 2016-11-03 13:38+0100, Paolo Bonzini: >> On 02/11/2016 22:05, Andrew Jones wrote: >>> On Wed, Nov 02, 2016 at 09:50:29PM +0100, Radim Krčmář wrote: >>>> Not doing so hid stderr output when the test was stuck and subsequently >>>> killed with ^C. >>>> >>>> Signed-off-by: Radim Krčmář >>>> --- >>>> scripts/arch-run.bash | 3 +-- >>>> 1 file changed, 1 insertion(+), 2 deletions(-) >>>> >>>> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash >>>> index 8e75c6ed6e17..326f59484e2b 100644 >>>> --- a/scripts/arch-run.bash >>>> +++ b/scripts/arch-run.bash >>>> @@ -30,12 +30,11 @@ run_qemu () >>>> >>>> # stdout to {stdout}, stderr to $errors >>>> exec {stdout}>&1 >>>> - errors=$("${@}" 2>&1 1>&${stdout}) >>>> + errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout}) >> >> What about: >> >> # preserve stdout and stderr output, but save stderr to $errors >> exec {stdout}>&1 {stderr}>&2 >> errors=$("$@" 2> >(tee /dev/fd/$stderr) > /dev/fd/$stdout) >> exec {stdout}>&- {stderr}>&- >> >> (Tested in the shell but not in arch-run.bash). > > Using files looks nicer, but is there a problem in the redirection? > I would rather use /dev/stderr or /dev/fd/2 directly if not. > > i.e. > exec {stdout}>&1 > errors=$("$@" 2> >(tee /dev/stderr) > /dev/fd/$stdout) > exec {stdout}>&- Yes, this works too. Paolo