This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [BZ #18433] Check file access/existence before forking.


On Fri, Sep 11, 2015 at 12:33:24PM +0300, Alexander Monakov wrote:
> On Fri, 11 Sep 2015, Florian Weimer wrote:
> > The downside is that this adds additional blocking to the posix_spawn
> > operation, which is not something all callers want (some may even prefer
> > that the vfork happens on a new thread).  So I think this needs a
> > configuration knob.
> 
> Huh?  By definition, the vfork parent is suspended until the vfork child
> either execs or terminates.  In both outcomes, the pipe will be already
> closed when the parent is resumed, so it will not block on reading.
> 
> (and if you can rely on parent-suspending semantics of vfork, you don't even
> need a pipe)
> 
> Unless I've missed something?

I've found CLONE_VFORK unreliable on Linux: under some conditions,
when running under ptrace, I observed the parent returning before the
child execs/exits, and of course horrible memory corruption resulted.
Thus I strongly prefer using CLONE_VFORK merely as a hint to the
scheduler (which helps prevent the extra blocking step in read) and
using FD_CLOEXEC for the actual synchronization.

Rich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]