svn commit: r291114 - head/lib/libc/gen
Andrey Chernov
ache at freebsd.org
Sat Nov 21 22:11:12 UTC 2015
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/
More information about the svn-src-head
mailing list