From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12461 Path: news.gmane.org!.POSTED!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] re-fix child reaping in wordexp Date: Mon, 5 Feb 2018 20:07:44 +0300 (MSK) Message-ID: References: <20180205143837.26009-1-amonakov@ispras.ru> <20180205162715.GW1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1517850376 22234 195.159.176.226 (5 Feb 2018 17:06:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Feb 2018 17:06:16 +0000 (UTC) User-Agent: Alpine 2.20.13 (LNX 116 2015-12-14) To: musl@lists.openwall.com Original-X-From: musl-return-12477-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 05 18:06:12 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eikDI-0004GE-Ad for gllmg-musl@m.gmane.org; Mon, 05 Feb 2018 18:05:52 +0100 Original-Received: (qmail 17905 invoked by uid 550); 5 Feb 2018 17:07:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 17878 invoked from network); 5 Feb 2018 17:07:55 -0000 In-Reply-To: <20180205162715.GW1627@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:12461 Archived-At: On Mon, 5 Feb 2018, Rich Felker wrote: > > In general retrying waitpid on EINTR is not robust in case pid reuse is > > possible, but fixing that requires changing waitpid call sites to only > > do that with signals blocked (where that's not already the case). > > I don't follow this. Unless there's a bug in the kernel, this should > not be functionally different from SA_RESTART. A return with EINTR > means the child was not reaped. The problem I had in mind is that you don't know if a signal handler or another thread had (yes, incorrectly) already reaped that child when you are about to retry waitpid. With signals blocked, you issue just one waitpid, and you need very rapid pid reuse to happen, after someone successfully reaps your child even before you enter waitpid. Of course this is a bit moot since the other thread/sighandler shouldn't be issuing wildcard waits in the first place, and if rapid pid reuse does not happen you safely leave the retry loop with ECHILD. But this is why I said "not robust" rather than "incorrect". Alexander