From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12456 Path: news.gmane.org!.POSTED!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] re-fix child reaping in wordexp Date: Mon, 5 Feb 2018 17:38:37 +0300 Message-ID: <20180205143837.26009-1-amonakov@ispras.ru> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1517841424 6038 195.159.176.226 (5 Feb 2018 14:37:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Feb 2018 14:37:04 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-12472-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 05 15:36:59 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 1eiht3-0000gT-SS for gllmg-musl@m.gmane.org; Mon, 05 Feb 2018 15:36:49 +0100 Original-Received: (qmail 7793 invoked by uid 550); 5 Feb 2018 14:38:50 -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 7758 invoked from network); 5 Feb 2018 14:38:49 -0000 X-Mailer: git-send-email 2.11.0 Xref: news.gmane.org gmane.linux.lib.musl.general:12456 Archived-At: 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. --- 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). 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