Author vstinner
Recipients alexey-smirnov, amaury.forgeotdarc, neologix, sbt, vstinner
Date 2013-01-03.15:23:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Recent version on different operating systems support opening a file with close-on-exec flag set immediatly (atomic). This feature fixes a race condition when the process calls execv() between open() and fcntl() (to set the FD_CLOEXEC flag to the newly opened file).

It would be nice to expose this feature in Python. The problem is the find a portable and safe way to expose the feature: neologix is against a best-effort function. For example, Linux kernel older than 2.6.22 simply ignores O_CLOEXEC flag (while the libc may expose it).

The feature looks to be supported by at least:

 * Linux kernel >= 2.6.23
 * FreeBSD 8+
 * Windows: _open(filename, _O_NOINHERIT). Is it supported by Windows XP and older versions?

See also:

 * Issue #12760 (closed): This issue added an "x" mode to open() to create a file in exclusive mode
 * Issue #12103: "Document how to use open with os.O_CLOEXEC"
 * Issue #12105: It was proposed to add an "e" mode to open() for O_CLOEXEC
Date User Action Args
2013-01-03 15:23:26vstinnersetrecipients: + vstinner, amaury.forgeotdarc, neologix, sbt, alexey-smirnov
2013-01-03 15:23:26vstinnersetmessageid: <>
2013-01-03 15:23:26vstinnerlinkissue16850 messages
2013-01-03 15:23:26vstinnercreate