[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] catch signals
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-devel] [PATCH] catch signals |
Date: |
Tue, 5 Aug 2008 17:35:19 +0100 |
User-agent: |
Mutt/1.4.1i |
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 :|