mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] re-fix child reaping in wordexp
Date: Mon, 5 Feb 2018 11:27:15 -0500	[thread overview]
Message-ID: <20180205162715.GW1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <20180205143837.26009-1-amonakov@ispras.ru>

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


  reply	other threads:[~2018-02-05 16:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 14:38 Alexander Monakov
2018-02-05 16:27 ` Rich Felker [this message]
2018-02-05 17:07   ` Alexander Monakov
2018-02-05 17:27     ` Rich Felker
2018-02-05 20:18       ` Alexander Monakov
2018-02-05 20:44         ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180205162715.GW1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).