From: Peter Maydell Date: Thu, 25 Sep 2014 15:51:09 +0000 (+0100) Subject: main-loop.c: Handle SIGINT, SIGHUP and SIGTERM synchronously X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=15124e142034d21341ec9f1a304a1dc5a6c25681;p=people%2Fliuw%2Flibxenctrl-split%2Fqemu-xen.git main-loop.c: Handle SIGINT, SIGHUP and SIGTERM synchronously 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 Reviewed-by: Paolo Bonzini Reviewed-by: Alex Bennée Tested-by: Alex Bennée Message-id: 1411660269-11081-1-git-send-email-peter.maydell@linaro.org Cc: qemu-stable@nongnu.org --- diff --git a/main-loop.c b/main-loop.c index 53393a4b1..d2e64f1fa 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);