From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12459 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] re-fix child reaping in wordexp Date: Mon, 5 Feb 2018 11:27:15 -0500 Message-ID: <20180205162715.GW1627@brightrain.aerifal.cx> References: <20180205143837.26009-1-amonakov@ispras.ru> 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 1517847955 422 195.159.176.226 (5 Feb 2018 16:25:55 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Feb 2018 16:25:55 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12475-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 05 17:25:51 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 1eija9-0006pJ-I7 for gllmg-musl@m.gmane.org; Mon, 05 Feb 2018 17:25:25 +0100 Original-Received: (qmail 1953 invoked by uid 550); 5 Feb 2018 16:27:27 -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 1929 invoked from network); 5 Feb 2018 16:27:27 -0000 Content-Disposition: inline In-Reply-To: <20180205143837.26009-1-amonakov@ispras.ru> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12459 Archived-At: On Mon, Feb 05, 2018 at 05:38:37PM +0300, Alexander Monakov wrote: > Do not retry waitpid if the child was terminated by a signal. Do not > examine status: since we are not passing any flags, we will not receive > stop or continue notifications. Looks fine. > --- > > 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. Rich > > src/misc/wordexp.c | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/src/misc/wordexp.c b/src/misc/wordexp.c > index db39b5b8..d123cf75 100644 > --- a/src/misc/wordexp.c > +++ b/src/misc/wordexp.c > @@ -14,13 +14,7 @@ > static void reap(pid_t pid) > { > int status; > - for (;;) { > - if (waitpid(pid, &status, 0) < 0) { > - if (errno != EINTR) return; > - } else { > - if (WIFEXITED(status)) return; > - } > - } > + while (waitpid(pid, &status, 0) < 0 && errno == EINTR); > } > > static char *getword(FILE *f) > -- > 2.11.0