From b879fabf36a45171cc35a894545e97c9a7be3bb8 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 22 Jun 2015 12:48:50 +0300 Subject: [PATCH] reactor: block SIGALRM while we're still not ready to handle it If some code sets up a timer before we've set up the SIGALRM signal handler, we die. Block it in the meantime. --- core/reactor.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/reactor.cc b/core/reactor.cc index 6e8d94ba5a..ba0651978d 100644 --- a/core/reactor.cc +++ b/core/reactor.cc @@ -204,6 +204,11 @@ reactor::reactor() sev.sigev_signo = SIGALRM; r = timer_create(CLOCK_REALTIME, &sev, &_timer); assert(r >= 0); + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, SIGALRM); + r = ::sigprocmask(SIG_BLOCK, &mask, NULL); + assert(r == 0); #endif memory::set_reclaim_hook([this] (std::function reclaim_fn) { // push it in the front of the queue so we reclaim memory quickly