summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2013-01-04 17:33:02 (GMT)
committerCharles-François Natali <neologix@free.fr>2013-01-04 17:33:02 (GMT)
commitb9a76e292088c4931460aec674ad5a4bd2f8c7a6 (patch)
treed395c196dac9b5dd41022c844ea3f56d9407a6e8 /Lib/tempfile.py
parent4e02538bf375fcdc8ebd0cdf24806014daf0c402 (diff)
downloadcpython-b9a76e292088c4931460aec674ad5a4bd2f8c7a6.zip
cpython-b9a76e292088c4931460aec674ad5a4bd2f8c7a6.tar.gz
cpython-b9a76e292088c4931460aec674ad5a4bd2f8c7a6.tar.bz2
Issue #16860: In tempfile, use O_CLOEXEC when available to set the
close-on-exec flag atomically.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 90b3c20..0aaee54 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -57,6 +57,8 @@ except ImportError:
_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'):