➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 vstinner
收信人 neologix, vstinner
日期 2013-01-04.14:22:28
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1357309349.04.0.535037454982.issue16860@psf.upfronthosting.co.za>
In-reply-to
内容
os.O_CLOEXEC has been added to Python 3.3. This flag solves a race condition if the process is forked between open() and a call to fcntl() to set the FD_CLOEXEC flag.

The following patch written by neologix should fix this issue:
"""
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -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'):
"""

The patch can be applied to Python 3.3 and 3.4.
历史
日期 用户 动作 参数
2013-01-04 14:22:29vstinner修改recipients: + vstinner, neologix
2013-01-04 14:22:29vstinner修改messageid: <1357309349.04.0.535037454982.issue16860@psf.upfronthosting.co.za>
2013-01-04 14:22:29vstinner链接issue16860 messages
2013-01-04 14:22:28vstinner创建