On Mon, Mar 14, 2011 at 02:58:55PM +0200, Gleb Natapov wrote: > Currently when rogue script kills QEMU process (using TERM/INT/HUP > signal) it looks indistinguishable from system shutdown. Lets report > that QMEU was killed and leave some clues about the killed identity.
Good idea, but.... > > Signed-off-by: Gleb Natapov <g...@redhat.com> > diff --git a/os-posix.c b/os-posix.c > index 38c29d1..7e175e8 100644 > --- a/os-posix.c > +++ b/os-posix.c > @@ -61,8 +61,9 @@ void os_setup_early_signal_handling(void) > sigaction(SIGPIPE, &act, NULL); > } > > -static void termsig_handler(int signal) > +static void termsig_handler(int signal, siginfo_t *info, void *c) > { > + fprintf(stderr, "Got signal %d from pid %d\n", info->si_signo, > info->si_pid); > qemu_system_shutdown_request(); ...fprintf() isn't async signal safe. It could deadlock the process if it malloc()s while doing the arg formatting & the interrupted thread was already holding a malloc() lock, or indeed if the stdio impl itself has internal locks which are held. So this data needs to be manually output using just write() Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|