提交 15124e14 编写于 作者: P Peter Maydell

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: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
Tested-by: NAlex Bennée <alex.bennee@linaro.org>
Message-id: 1411660269-11081-1-git-send-email-peter.maydell@linaro.org
Cc: qemu-stable@nongnu.org
上级 6a0fcbdf
...@@ -84,6 +84,9 @@ static int qemu_signal_init(void) ...@@ -84,6 +84,9 @@ static int qemu_signal_init(void)
sigaddset(&set, SIGIO); sigaddset(&set, SIGIO);
sigaddset(&set, SIGALRM); sigaddset(&set, SIGALRM);
sigaddset(&set, SIGBUS); sigaddset(&set, SIGBUS);
sigaddset(&set, SIGINT);
sigaddset(&set, SIGHUP);
sigaddset(&set, SIGTERM);
pthread_sigmask(SIG_BLOCK, &set, NULL); pthread_sigmask(SIG_BLOCK, &set, NULL);
sigdelset(&set, SIG_IPI); sigdelset(&set, SIG_IPI);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册