Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug with eval, proc-subst and pipes



Note, there are at least three messages in this thread that I've never
received ... they don't seem to be in my spam folder, either ...

On Saturday, July 20, 2013, Peter Stephenson wrote:

> On Fri, 19 Jul 2013 21:58:53 +0100
> Stephane Chazelas <stephane.chazelas@xxxxxxxxx <javascript:;>> wrote:
> > and fd 13 by closedumps() (the missing link to compinit?).
>
> That's distinctly suspicious, if 13 was opened for the process
> substitution.
>
> Does the following fix it, or is there yet more?


Something doesn't look right about this patch, but I've only looked at the
patch itself, not at the context (I'm away from my usual computers at the
moment).  The #ifndef lines seem to put both a functional and a no-op
version of closedumps() in the same not-FD_CLOEXEC context?  And if
closedumps() was a no-op with FD_CLOEXEC before (?) then would it change
anything to remove it at the point of call?

(Pardon the excessive quoting below.)


If it does we still have an error for older systems, but I suspect
> FD_CLOEXEC (and O_CLOEXEC) are widely enough supported that may be more
> a theoretical then an actual problem.
>
> diff --git a/Src/exec.c b/Src/exec.c
> index d462d97..f9efb3a 100644
> --- a/Src/exec.c
> +++ b/Src/exec.c
> @@ -448,7 +448,9 @@ zexecve(char *pth, char **argv, char **newenvp)
>      else
>         sprintf(buf + 2, "%s/%s", pwd, pth);
>      zputenv(buf);
> +#ifndef FD_CLOEXEC
>      closedumps();
> +#endif
>
>      if (newenvp == NULL)
>             newenvp = environ;
> diff --git a/Src/parse.c b/Src/parse.c
> index 753080d..b670925 100644
> --- a/Src/parse.c
> +++ b/Src/parse.c
> @@ -3171,6 +3171,9 @@ load_dump_file(char *dump, struct stat *sbuf, int
> other, int len)
>      d->dev = sbuf->st_dev;
>      d->ino = sbuf->st_ino;
>      d->fd = fd;
> +#ifdef FD_CLOEXEC
> +    fcntl(fd, F_SETFD, FD_CLOEXEC);
> +#endif
>      d->map = addr + (other ? (len - off) / sizeof(wordcode) : 0);
>      d->addr = addr;
>      d->len = len;
> @@ -3439,6 +3442,7 @@ decrdumpcount(FuncDump f)
>      }
>  }
>
> +#ifndef FD_CLOEXEC
>  /**/
>  mod_export void
>  closedumps(void)
> @@ -3448,6 +3452,7 @@ closedumps(void)
>      for (p = dumps; p; p = p->next)
>         zclose(p->fd);
>  }
> +#endif
>
>  #else
>
> @@ -3461,11 +3466,13 @@ decrdumpcount(FuncDump f)
>  {
>  }
>
> +#ifndef FD_CLOEXEC
>  /**/
>  mod_export void
>  closedumps(void)
>  {
>  }
> +#endif
>
>  #endif
>
> --
> Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx <javascript:;>>
> Web page now at http://homepage.ntlworld.com/p.w.stephenson/
>


Messages sorted by: Reverse Date, Date, Thread, Author