From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [kvm-unit-tests PATCH] scripts/arch-run: print stderr immediately Date: Thu, 3 Nov 2016 13:53:32 +0100 Message-ID: <20161103125332.GC7771@potion> References: <20161102205029.880-1-rkrcmar@redhat.com> <20161102210548.vwzhlrrv7qd6vuba@kamzik.brq.redhat.com> <7f385e31-cf44-758d-9d81-5151823b5395@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: Andrew Jones , kvm@vger.kernel.org To: Paolo Bonzini Return-path: Received: from mx1.redhat.com ([209.132.183.28]:33590 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752503AbcKCMxg (ORCPT ); Thu, 3 Nov 2016 08:53:36 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CDA7A4E328 for ; Thu, 3 Nov 2016 12:53:35 +0000 (UTC) Content-Disposition: inline In-Reply-To: <7f385e31-cf44-758d-9d81-5151823b5395@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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}>&-