Author neologix
Recipients alexey-smirnov, amaury.forgeotdarc, christian.heimes, neologix, pitrou, rosslagerwall, sbt, vstinner
Date 2013-01-04.14:17:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
> O_CLOEXEC solves for example a race condition in tempfile._mkstemp_inner():
>             fd =, flags, 0o600)
>             _set_cloexec(fd)

diff --git a/Lib/ b/Lib/
--- a/Lib/
+++ b/Lib/
@@ -57,6 +57,8 @@
 _allocate_lock = _thread.allocate_lock

 _text_openflags = _os.O_RDWR | _os.O_CREAT | _os.O_EXCL
+if hasattr(_os, 'O_CLOEXEC'):
+    _text_openflags |= _os.O_CLOEXEC
 if hasattr(_os, 'O_NOINHERIT'):
     _text_openflags |= _os.O_NOINHERIT
 if hasattr(_os, 'O_NOFOLLOW'):

We should probably add this to 3.3 and default (IIRC O_CLOEXEC was
added to the os module in 3.3).
Also, I think O_NOFOLLOW is useless: if the file is created
(O_EXCL|O_CREAT), then by definition it's not a symlink (juste check
glibc's mkstemp() implementation, and it only passes O_CREAT|O_EXCL).
Date User Action Args
2013-01-04 14:17:25neologixsetrecipients: + neologix, amaury.forgeotdarc, pitrou, vstinner, christian.heimes, rosslagerwall, sbt, alexey-smirnov
2013-01-04 14:17:25neologixlinkissue16850 messages
2013-01-04 14:17:25neologixcreate