From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54274 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pz7Uy-0004Gb-Nz for qemu-devel@nongnu.org; Mon, 14 Mar 2011 09:07:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pz7Uw-0003T4-TJ for qemu-devel@nongnu.org; Mon, 14 Mar 2011 09:07:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pz7Uw-0003Sw-Hh for qemu-devel@nongnu.org; Mon, 14 Mar 2011 09:07:46 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2ED7ie7013264 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 14 Mar 2011 09:07:44 -0400 Date: Mon, 14 Mar 2011 13:07:40 +0000 From: "Daniel P. Berrange" Subject: Re: [Qemu-devel] [PATCH] report that QEMU process was killed by a signal Message-ID: <20110314130740.GC23458@redhat.com> References: <20110314125855.GP10151@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20110314125855.GP10151@redhat.com> Reply-To: "Daniel P. Berrange" List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: qemu-devel@nongnu.org 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 > 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 :|