Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Nov 2015 01:11:05 +0300
From:      Andrey Chernov <ache@freebsd.org>
To:        David Sanderson <yelliott@gmail.com>
Cc:        Ravi Pokala <rpokala@mac.com>, Ravi Pokala <rpokala@freebsd.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, "Sanderson, David" <dws@panasas.com>
Subject:   Re: svn commit: r291114 - head/lib/libc/gen
Message-ID:  <5650EBF9.9060002@freebsd.org>
In-Reply-To: <CAC-6ESEyonTpaL9ZaRGcER20ZFJVmRzF22G4M%2BT9Y6EPLTOyPA@mail.gmail.com>
References:  <201511202236.tAKMaf06048447@repo.freebsd.org> <564FAAB0.6000600@freebsd.org> <28C3C55F-BF25-4DB2-AF05-B57F3F2CCAD5@panasas.com> <564FB5F3.1080301@freebsd.org> <CAC-6ESEyonTpaL9ZaRGcER20ZFJVmRzF22G4M%2BT9Y6EPLTOyPA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 21.11.2015 5:29, David Sanderson wrote:
> Thank you for pointing out the possibility of fdopen() setting
> FD_CLOEXEC on the parent's end of the pipe if the mode string contains
> an 'e'.  This is indeed documented on popen(3).
> 
> However, note that popen() uses pipe2(pdes, O_CLOEXEC) to create the
> pipe -- so both ends of the pipe start out with FD_CLOEXEC set.
> 
> If the caller uses popen() with "re" or "we", the fdopen() code will
> simply set FD_CLOEXEC on the parent's end of the pipe _again_.  So
> moving the fdopen() prior to the fork() doesn't have any net effect on
> the file descriptors the child process receives, even in the face of
> popen() with "re" or "we".
> 
> Does this address your concerns?

Yes, it is safe in this case. Thanx.

-- 
http://ache.vniz.net/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5650EBF9.9060002>