From patchwork Wed Jun 8 22:55:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 99583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8554BB6FDC for ; Thu, 9 Jun 2011 08:59:47 +1000 (EST) Received: from localhost ([::1]:55698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QURiw-0006I0-O2 for incoming@patchwork.ozlabs.org; Wed, 08 Jun 2011 18:59:42 -0400 Received: from eggs.gnu.org ([140.186.70.92]:50627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QURg7-0006E2-U0 for qemu-devel@nongnu.org; Wed, 08 Jun 2011 18:56:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QURg6-0002u0-1B for qemu-devel@nongnu.org; Wed, 08 Jun 2011 18:56:47 -0400 Received: from cantor.suse.de ([195.135.220.2]:52518 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QURg5-0002tj-Ne for qemu-devel@nongnu.org; Wed, 08 Jun 2011 18:56:45 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 787FC6CB00; Thu, 9 Jun 2011 00:56:43 +0200 (CEST) From: Alexander Graf To: qemu-devel Developers Date: Thu, 9 Jun 2011 00:55:37 +0200 Message-Id: <1307573737-33421-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.2 Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Jan Kiszka Subject: [Qemu-devel] [PATCH] sigfd: use pthread_sigmask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;