qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] catch signals
Date: Tue, 5 Aug 2008 17:35:19 +0100	[thread overview]
Message-ID: <20080805163519.GV6570@redhat.com> (raw)
In-Reply-To: <48987B43.4090207@redhat.com>

On Tue, Aug 05, 2008 at 06:09:39PM +0200, Gerd Hoffmann wrote:
>  
> +#ifndef _WIN32
> +static void termsig_handler(int signal)
> +{
> +    switch (signal) {
> +    case SIGSEGV:
> +    case SIGBUS:
> +        /* returning from signal handler most likely isn't going to work */
> +        fprintf(stderr, "qemu: got signal %d (%s), taking emergency exit\n",
> +                signal, strsignal(signal));
> +        exit(1);

Neither of these functions are on the POSIX  async-signal-safe list,
so their use from signal handlers is not a good idea.

'man 7 signal' will detail the safe functions that can be used from
signal handlers. http://kerneltrap.org/man/linux/man7/signal.7

> +        break;
> +    default:
> +        qemu_system_shutdown_request();

This is ok it merely sets a flag

> +        vm_start();	/* In case we're paused */

I've not checked all the functions this calls to see if they
are safe, but I have a feeling this won't be safe in general
because the vm_state_notify() will invoke a number of callbacks
whose content we can't predict.

I think rather than trying todo anything in the signal handler,
it is safest to just set a flag and have its state checked
and acted upon in the main loop.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

  parent reply	other threads:[~2008-08-05 16:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-05 16:09 [Qemu-devel] [PATCH] catch signals Gerd Hoffmann
2008-08-05 16:29 ` Samuel Thibault
2008-08-06  9:11   ` Gerd Hoffmann
2008-08-05 16:35 ` Daniel P. Berrange [this message]
2008-08-05 16:53   ` Samuel Thibault
2008-08-05 17:00     ` Daniel P. Berrange
2008-08-05 18:39       ` Jamie Lokier
2008-08-06  9:20   ` Gerd Hoffmann
2008-08-06  9:48     ` Daniel P. Berrange
2008-08-11 16:50 ` Ian Jackson
2008-08-11 19:43   ` Gerd Hoffmann

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=20080805163519.GV6570@redhat.com \
    --to=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).