qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Subject: Re: [Qemu-devel] [PATCH] catch signals
Date: Tue, 5 Aug 2008 19:39:51 +0100	[thread overview]
Message-ID: <20080805183951.GC28513@shareable.org> (raw)
In-Reply-To: <20080805170048.GY6570@redhat.com>

Daniel P. Berrange wrote:
> On Tue, Aug 05, 2008 at 05:53:21PM +0100, Samuel Thibault wrote:
> > Daniel P. Berrange, le Tue 05 Aug 2008 17:35:19 +0100, a écrit :
> > > 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.
> > 
> > We can not do that for SIGSEGV/SIGBUS, however.
> 
> We shouldn't be trying todo anything for SEGV/BUS. It is basically game
> over at that point - you've no chance of orderly shutdown. Only QUIT, INT,
> TERM, HUP should be trying todo graceful shutdown, because those don't
> imply your process is corrupting its memory/ doing bad stuff.

If you can detect _where_ is triggering SIGSEGV/SIGBUS, and it's in
generated code, then you've got a good chance of treating it as a
special kind of trap and aborting cleanly.

Also, while orderly shutdown is not possible, some subsystems could
register an "emergency shutdown" hook which is async-signal-safe.

Logging would have to be disabled during them, and they'd just do
things to tidy up, e.g. unlinking temporary files, writing memory/disk
state to an emergency snapshot if that's possible, complete pending
writes to disk image formats if that makes them safer.

I do something like that in a program of mine: register cleanup
handlers, and some of them say "can be called from an emergency signal".

Finally, another reason to have emergency cleanups is when you send
SIGTERM but it's wedged, and the main loop isn't responding.  After a
while, you want to kill the thing, and a bit of signal-safe cleanup
then is good.

-- Jamie

  reply	other threads:[~2008-08-05 18:40 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
2008-08-05 16:53   ` Samuel Thibault
2008-08-05 17:00     ` Daniel P. Berrange
2008-08-05 18:39       ` Jamie Lokier [this message]
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=20080805183951.GC28513@shareable.org \
    --to=jamie@shareable.org \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@ens-lyon.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).