From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: peter.maydell@linaro.org, mst@redhat.com, f4bug@amsat.org,
qemu-devel@nongnu.org, alex.bennee@linaro.org, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v2 for-3.0] tests/libqtest: Improve kill_qemu()
Date: Wed, 25 Jul 2018 18:17:01 +0200 [thread overview]
Message-ID: <878t5zxpc2.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <8c082bfd-6753-c8d2-cfcd-e2be77c3f763@redhat.com> (Eric Blake's message of "Tue, 24 Jul 2018 09:35:58 -0500")
Eric Blake <eblake@redhat.com> writes:
> On 07/24/2018 01:36 AM, Markus Armbruster wrote:
>> Eric Blake <eblake@redhat.com> writes:
>>
>>> In kill_qemu() we have an assert that checks that the QEMU process
>>> didn't dump core:
>>> assert(!WCOREDUMP(wstatus));
>>>
>>> Unfortunately the WCOREDUMP macro here means the resulting message
>>> is not very easy to comprehend on at least some systems:
>>>
>
>>> - if (pid == s->qemu_pid && WIFSIGNALED(wstatus)) {
>>> - assert(!WCOREDUMP(wstatus));
>
>>> + } else if (WIFSIGNALED(wstatus)) {
>>> + int sig = WTERMSIG(wstatus);
>>> + const char *signame = strsignal(sig) ?: "unknown ???";
>>> +
>>> + if (!WCOREDUMP(wstatus)) {
>>> + die = false;
>>
>> Does WCOREDUMP(wstatus) depend on the user's ulimit -c?
>
> 'man waitpid' on Linux mentions that WCOREDUMP is nonportable, but
> does not mention any interaction with setrlimit. But a quick test
> shows:
>
> $ ulimit -S -c 0
> $ cat foo.c
> int main(int argc, char **argv) {
> return *argv[1];
> }
> $ gcc -o foo -Wall foo.c
> $ ./foo 1
> $ ./foo
> Segmentation fault (core dumped)
> $
>
> the output was produced by bash, which uses waitpid() - and therefore
> the fact that bash reports the core dump even when no core file is
> created is promising.
Proof beats plausibility argument:
$ cat wcordump.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
int
main(void)
{
pid_t child = fork();
int wstatus;
if (child < 0) {
perror("fork");
exit(1);
}
if (!child) {
abort();
}
if (waitpid(child, &wstatus, 0) < 0) {
perror("waitpid");
exit(1);
}
if (WIFSIGNALED(wstatus)) {
printf("sig %d %d\n",
WTERMSIG(wstatus), WCOREDUMP(wstatus));
} else {
printf("no sig\n");
}
exit(0);
}
$ gcc -Wall -g -O wcordump.c
$ (ulimit -c unlimited; ./a.out)
sig 6 128
$ (ulimit -c 0; ./a.out)
sig 6 0
Looks like WCOREDUMP() does depend on my ulimit -c.
next prev parent reply other threads:[~2018-07-25 16:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-23 19:35 [Qemu-devel] [PATCH v2 for-3.0] tests/libqtest: Improve kill_qemu() Eric Blake
2018-07-23 20:20 ` Richard Henderson
2018-07-24 6:36 ` Markus Armbruster
2018-07-24 14:35 ` Eric Blake
2018-07-25 16:17 ` Markus Armbruster [this message]
2018-07-30 21:24 ` Eric Blake
2018-07-31 5:35 ` Markus Armbruster
2018-07-24 6:44 ` Thomas Huth
2018-07-30 21:26 ` Eric Blake
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=878t5zxpc2.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=eblake@redhat.com \
--cc=f4bug@amsat.org \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.