From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id nybHA7/dyGDmbAAAWB0awg (envelope-from ) for ; Tue, 15 Jun 2021 13:05:03 -0400 Received: by simark.ca (Postfix, from userid 112) id F29A11F163; Tue, 15 Jun 2021 13:05:02 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C549C1E939 for ; Tue, 15 Jun 2021 13:05:01 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A8CC3847808 for ; Tue, 15 Jun 2021 17:05:01 +0000 (GMT) Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id BD3B5385B804 for ; Tue, 15 Jun 2021 17:04:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BD3B5385B804 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 0720E85DA9; Tue, 15 Jun 2021 17:04:47 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G4F6k6XFgz4gp4; Tue, 15 Jun 2021 17:04:46 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 84F4E2AD03; Tue, 15 Jun 2021 17:04:46 +0000 (UTC) (envelope-from jhb@FreeBSD.org) To: Pedro Alves , gdb-patches@sourceware.org References: <20210615111429.1879286-1-pedro@palves.net> From: John Baldwin Subject: Re: [PATCH 0/4] Introduce scoped_ignore_signal & make it thread safe Message-ID: Date: Tue, 15 Jun 2021 10:04:45 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210615111429.1879286-1-pedro@palves.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 6/15/21 4:14 AM, Pedro Alves wrote: > For the Ctrl-C rework series I posted recently, I stared at code using > scoped_ignore_sigttou a lot, and it annoyed me that it isn't thread > safe, because it changes the signal's disposition. > > Very recently, we got a new scoped_ignore_sigpipe class modelled on > scoped_ignore_sigttou, which made me want to fix this before it ever > becomes a (hard to debug) problem. I mentioned this here: > > https://sourceware.org/pipermail/gdb-patches/2021-June/179958.html I think this looks ok to me. The one difference I can think of when using sigpromask() instead of SIG_IGN is if the signal might be sent to another thread instead of masked. However, both SIGPIPE and SIGTTOU sent in the context of write() should be sent to the specific thread calling write(). SIGTTOU is a bit funky in that it gets raised to the entire process group, but in FreeBSD at least we only raise it if it is not masked for the current thread that has invoked write(). (If the signal is masked, it isn't raised at all.) -- John Baldwin