HomeFreeBSD

popen(): Add 'e' mode character to set close-on-exec on the new fd.
rS250827Unpublished

Unpublished Commit ยท Learn More

No further details are available.

Description

popen(): Add 'e' mode character to set close-on-exec on the new fd.

If 'e' is used, the kernel must support the recently added pipe2() system
call.

The use of pipe2() with O_CLOEXEC also fixes race conditions between
concurrent popen() calls from different threads, even if the close-on-exec
flag on the fd of the returned FILE is later cleared (because popen() closes
all file descriptors from earlier popen() calls in the child process).
Therefore, this approach should be used in all cases when pipe2() can be
assumed present.

The old version of popen() rejects "re" and "we" but treats "r+e" like "r+".

Details

Provenance
jillesAuthored on
Parents
rS250826: NetBSD 6.1 added.
Branches
Unknown
Tags
Unknown

Event Timeline