qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] curses: fixup SIGWINCH handler mess


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] curses: fixup SIGWINCH handler mess
Date: Tue, 12 Nov 2013 13:16:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9

Il 12/11/2013 12:53, Laszlo Ersek ha scritto:
> Also, I grepped the source for SIGWINCH, and I think it is never masked
> with pthread_sigmask(), or -- while the process is single-threaded
> initially -- with sigprocmask(). Hence this signal can be delivered at
> any time and interrupt interruptible functions (which is good
> justification for the patch.) My point though is that after this patch a
> narrow window seems to exist where you can lose a signal, namely between
> checking "got_sigwinch" and resetting it.

You don't really lose it, it is delayed to the next refresh.

> (SIGWINCH is not a standard signal but I do think it it's not a realtime
> one, hence it doesn't queue up; it can only be pending or not.)

Indeed.

> For ultimate pedantry we could maybe write
> 
>     bool local;
> 
>     /* block the signal with pthread_sigmask()
>      * for atomic retrieval and reset
>      */
>     local = got_sigwinch;
>     got_sigwinch = false;
>     /* unblock the signal */
> 
>     if (!local) {
>         return;
>     }
> 
> but it's likely overkill.

Or just use an atomic function:

    if (!atomic_xchg(&got_sigwinch, false)) {
        return;
    }

Paolo



reply via email to

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