qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] sigfd: use pthread_sigmask


From: Jan Kiszka
Subject: Re: [Qemu-devel] [PATCH] sigfd: use pthread_sigmask
Date: Thu, 09 Jun 2011 08:51:51 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

On 2011-06-09 00:55, Alexander Graf wrote:
> 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 <address@hidden>
> CC: Paolo Bonzini <address@hidden>
> CC: Jan Kiszka <address@hidden>
> CC: Anthony Liguori <address@hidden>
> Signed-off-by: Alexander Graf <address@hidden>
> ---
>  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;

Makes a lot of sense. And it also effects pre-signalfd Linux (<2.6.27).

Acked-by: Jan Kiszka <address@hidden>

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]