From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgCtq-0000sO-8l for qemu-devel@nongnu.org; Tue, 12 Nov 2013 07:17:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgCth-0000xE-SV for qemu-devel@nongnu.org; Tue, 12 Nov 2013 07:16:54 -0500 Received: from mail-ea0-x22e.google.com ([2a00:1450:4013:c01::22e]:47848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgCth-0000wk-Lo for qemu-devel@nongnu.org; Tue, 12 Nov 2013 07:16:45 -0500 Received: by mail-ea0-f174.google.com with SMTP id n15so2832466ead.33 for ; Tue, 12 Nov 2013 04:16:44 -0800 (PST) Sender: Paolo Bonzini Message-ID: <52821C29.5020005@redhat.com> Date: Tue, 12 Nov 2013 13:16:41 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1384245814-15010-1-git-send-email-kraxel@redhat.com> <528216C7.10705@redhat.com> In-Reply-To: <528216C7.10705@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] curses: fixup SIGWINCH handler mess List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: Gerd Hoffmann , Anthony Liguori , qemu-devel@nongnu.org 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