qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, Fam Zheng <famz@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
Date: Tue, 13 May 2014 13:30:05 -0600	[thread overview]
Message-ID: <537272BD.4020802@redhat.com> (raw)
In-Reply-To: <87a9aly3nx.fsf@blackfin.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 2182 bytes --]

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 @@
>>
>>      == Creating a dirty image file ==
>>      Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
>>     +./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?
> 

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 <stdlib.h>
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)

> 
> It goes away when I redirect the output *within* the function:
> 
> 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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-05-13 20:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13  8:46 [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039 Markus Armbruster
2014-05-13  9:22 ` Fam Zheng
2014-05-13 11:30   ` Markus Armbruster
2014-05-13 12:43     ` Fam Zheng
2014-05-13 17:44   ` Markus Armbruster
2014-05-13 19:30     ` Eric Blake [this message]
2014-05-14  7:58     ` Kevin Wolf
2014-05-14  9:25       ` Markus Armbruster
2014-05-14 11:16         ` Markus Armbruster
2014-05-14 11:42           ` Kevin Wolf
  -- strict thread matches above, loose matches on Subject: below --
2014-05-14 13:12 Markus Armbruster
2014-05-14 13:28 ` Fam Zheng
2014-05-14 14:28   ` Kevin Wolf
2014-05-26  9:10     ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=537272BD.4020802@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).