This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] [BZ #18433] Check file access/existence before forking.
- From: navid Rahimi <rahimi dot nv at gmail dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: Zack Weinberg <zackw at panix dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 11 Sep 2015 14:04:42 +0430
- Subject: Re: [PATCH] [BZ #18433] Check file access/existence before forking.
- Authentication-results: sourceware.org; auth=none
- References: <55F19819 dot 3010601 at gmail dot com> <ACDB9D4B-30B6-46C1-9286-5F03594CEACC at panix dot com> <CAOUBrm3oeUVDM-q4VFP08gjEkD2UFaz0Xfq1oGBW+m76rDRu+A at mail dot gmail dot com> <CAKCAbMiYkywWeSiJ5jkH7r8eYMSOWFmYDsjEN3k5ZaTPEeJGXw at mail dot gmail dot com> <55F29C54 dot 5010809 at redhat dot com>
On Fri, Sep 11, 2015 at 1:48 PM, Florian Weimer <fweimer@redhat.com> wrote:
> The correct way is to set up a pipe with O_CLOEXEC file descriptors in
> the parent prior to forking. The parent reads from the pipe after
> forking, waiting. When the execve succeeds, the read in the parent
> completes without returning any data. On execve failure, the child
> writes the errno value over the pipe, where the parent can read it and
> report it.
I was reading musl source code to figure it out how they handle this
situation , they use exact same method . They use pipe's to get
situation of child .The main key point here is the closure of pipe in
successful execve(O_CLOEXEC).
Implementation of it is not hard at all. I will work on patch to send in days.