qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] catch signals


From: Jamie Lokier
Subject: Re: [Qemu-devel] [PATCH] catch signals
Date: Tue, 5 Aug 2008 19:39:51 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]