Message179023
| Author |
vstinner |
| Recipients |
neologix, vstinner |
| Date |
2013年01月04日.14:22:28 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1357309349.04.0.535037454982.issue16860@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2013年01月04日 14:22:29 | vstinner | set | recipients:
+ vstinner, neologix |
| 2013年01月04日 14:22:29 | vstinner | set | messageid: <1357309349.04.0.535037454982.issue16860@psf.upfronthosting.co.za> |
| 2013年01月04日 14:22:29 | vstinner | link | issue16860 messages |
| 2013年01月04日 14:22:28 | vstinner | create |
|