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