From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkJDy-0003s0-C8 for qemu-devel@nongnu.org; Tue, 13 May 2014 16:22:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkJDt-0003yW-E6 for qemu-devel@nongnu.org; Tue, 13 May 2014 16:22:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkJDt-0003yS-6V for qemu-devel@nongnu.org; Tue, 13 May 2014 16:22:49 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4DKMmCQ010620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 13 May 2014 16:22:48 -0400 Message-ID: <537272BD.4020802@redhat.com> Date: Tue, 13 May 2014 13:30:05 -0600 From: Eric Blake MIME-Version: 1.0 References: <1399970763-8102-1-git-send-email-armbru@redhat.com> <20140513092211.GD26360@T430.nay.redhat.com> <87a9aly3nx.fsf@blackfin.pond.sub.org> In-Reply-To: <87a9aly3nx.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1S5ihWWPl6FngbV3hsF7MiAlBe1t4CFel" Subject: Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Fam Zheng Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1S5ihWWPl6FngbV3hsF7MiAlBe1t4CFel Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/13/2014 11:44 AM, Markus Armbruster wrote: >> But when I try to put this in a function to avoid repeating: >> >> function _no_dump_exec() >> { >> (ulimit -c 0; exec "$@") >> } >> >> _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_= IMG") | _filter_qemu_io >> >> it doesn't work: >> >> 039 1s ... - output mismatch (see 039.out.bad) >> --- 039.out 2014-05-13 12:10:39.248866480 +0800 >> +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800 >> @@ -9,6 +9,7 @@ >> >> =3D=3D Creating a dirty image file =3D=3D >> Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 >> +./039: line 51: 10517 Aborted "$@" >> wrote 512/512 bytes at offset 0 >> 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) >> incompatible_features 0x1 >> >> Any idea what the difference is here? >=20 At least in bash, the shell does error reporting any time the last command in a pipeline exits via a signal. By factoring things into a function, you've changed from a 2-command pipeline where the abort was on the left to a (trivial one-command) pipeline; therefore, now that the shell is executing a pipeline that exits via signal, it gets verbose. dash, on the other hand, reports an abort no matter where in the pipeline it occurs: $ cat foo.c #include int main(void) { abort(); } $ bash -c './foo;:' bash: line 1: 5706 Aborted (core dumped) ./foo $ bash -c './foo|:;:' $ dash -c './foo;:' Aborted (core dumped) $ dash -c './foo|:;:' Aborted (core dumped) >=20 > It goes away when I redirect the output *within* the function: >=20 > function _no_dump_exec() > { > "$@" | cat > } Yes, for bash, because that once again puts your command on the left of the pipeline, with the right side no longer exiting via a signal. But unless this script is specifically running on bash, you are not portable to dash unless you manually redirect the expected stderr blurb from the shell to /dev/null. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --1S5ihWWPl6FngbV3hsF7MiAlBe1t4CFel Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTcnK9AAoJEKeha0olJ0NqID8H/ihmIeGMTqpe1+D0FMuq+YuW G3HY3+zd99ZLFK/gl+xEL9UliEHm3w6mK/Z50od06huOxebQtPqvsDbMtoTuAcUV qVZhVhl/Thv6a5pK+UQPTakeVn0Y+Tv+h3avP2IHXlmBajRMzHAG/y9pyCh92YBO N6kzXAOfUX0WedQHqby2YkNg3s0sfY4bLCeCczLAyo2b92Y9Snsb6yMt/nND0C0I alGfpWXd33ntc2ONWvUuAMAXDXNmlX/zDBLVNC+N3ayh6RACphJptFMCcfAVxU3W IB41bxu7FFUrbnNvU9xRXZ2uVYinpvKHcnYPkx4WFQJzfFmBeCPWj3HEg18H9ts= =cKIB -----END PGP SIGNATURE----- --1S5ihWWPl6FngbV3hsF7MiAlBe1t4CFel--