From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXBKF-0005T8-1E for qemu-devel@nongnu.org; Thu, 25 Sep 2014 11:51:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXBKE-0002fO-2b for qemu-devel@nongnu.org; Thu, 25 Sep 2014 11:51:22 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:54059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXBKD-0002dZ-Sz for qemu-devel@nongnu.org; Thu, 25 Sep 2014 11:51:22 -0400 From: Peter Maydell Date: Thu, 25 Sep 2014 16:51:09 +0100 Message-Id: <1411660269-11081-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH] main-loop.c: Handle SIGINT, SIGHUP and SIGTERM synchronously List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Hajnoczi , patches@linaro.org Add the termination signals SIGINT, SIGHUP and SIGTERM to the list of signals which we handle synchronously via a signalfd. This avoids a race condition where if we took the SIGTERM in the middle of qemu_shutdown_requested: int r = shutdown_requested; [SIGTERM here...] shutdown_requested = 0; then the setting of the shutdown_requested flag by termsig_handler() would be lost and QEMU would fail to shut down. This was causing 'make check' to hang occasionally. Signed-off-by: Peter Maydell Cc: qemu-stable@nongnu.org --- main-loop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main-loop.c b/main-loop.c index 3cc79f8..8746abc 100644 --- a/main-loop.c +++ b/main-loop.c @@ -84,6 +84,9 @@ static int qemu_signal_init(void) sigaddset(&set, SIGIO); sigaddset(&set, SIGALRM); sigaddset(&set, SIGBUS); + sigaddset(&set, SIGINT); + sigaddset(&set, SIGHUP); + sigaddset(&set, SIGTERM); pthread_sigmask(SIG_BLOCK, &set, NULL); sigdelset(&set, SIG_IPI); -- 1.9.1