Skip to content

Commit

Permalink
main-loop.c: Handle SIGINT, SIGHUP and SIGTERM synchronously
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Message-id: [email protected]
Cc: [email protected]
  • Loading branch information
pm215 committed Sep 26, 2014
1 parent 6a0fcbd commit 15124e1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main-loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 15124e1

Please sign in to comment.