]> granicus.if.org Git - python/commitdiff
Issue #16860: In tempfile, use O_CLOEXEC when available to set the
authorCharles-François Natali <neologix@free.fr>
Fri, 4 Jan 2013 17:33:02 +0000 (18:33 +0100)
committerCharles-François Natali <neologix@free.fr>
Fri, 4 Jan 2013 17:33:02 +0000 (18:33 +0100)
close-on-exec flag atomically.

Lib/tempfile.py
Misc/NEWS

index 90b3c20ac4ffec423cd793c6be880d65d407af04..0aaee541c3bb1c92ff382a3effc91016bcbd7d4d 100644 (file)
@@ -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'):
index e63803960cb52eccd0152678f685d78cc0c062fa..284ce1a3bc5e4da388e37dad3c603345c68f7827 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -204,6 +204,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #16860: In tempfile, use O_CLOEXEC when available to set the
+  close-on-exec flag atomically.
+
 - Issue #16674: random.getrandbits() is now 20-40% faster for small integers.
 
 - Issue #16009: JSON error messages now provide more information.