From patchwork Wed Jun 8 22:55:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: sigfd: use pthread_sigmask Date: Wed, 08 Jun 2011 12:55:37 -0000 From: Alexander Graf X-Patchwork-Id: 99583 Message-Id: <1307573737-33421-1-git-send-email-agraf@suse.de> To: qemu-devel Developers Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Jan Kiszka Qemu uses signalfd to figure out, if a signal occured without the need to actually receive the signal. Instead, it can read from the fd to receive its news. Now, we obviously don't always have signalfd around. Especially not on non-Linux systems. So what we do there is that we create a new thread, block that thread on all signals and simply call sigwait to wait for a signal we're interested in to occur. This all sounds great, but what we're really doing is: sigset_t all; sigfillset(&all); sigprocmask(SIG_BLOCK, &all, NULL); which - on Darwin - blocks all signals on the current _process_, not only on the current thread. To block signals on the thread, we can use pthread_sigmask(). This patch does that, assuming that my above analysis is correct, and thus renders Qemu useable on Darwin again. Reported-by: Andreas Färber CC: Paolo Bonzini CC: Jan Kiszka CC: Anthony Liguori Signed-off-by: Alexander Graf Acked-by: Paolo Bonizni Acked-by: Jan Kiszka Acked-by: Andreas Färber --- compatfd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/compatfd.c b/compatfd.c index bd377c4..41586ce 100644 --- a/compatfd.c +++ b/compatfd.c @@ -29,7 +29,7 @@ static void *sigwait_compat(void *opaque) sigset_t all; sigfillset(&all); - sigprocmask(SIG_BLOCK, &all, NULL); + pthread_sigmask(SIG_BLOCK, &all, NULL); while (1) { int sig;