From b9a76e292088c4931460aec674ad5a4bd2f8c7a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Fri, 4 Jan 2013 18:33:02 +0100 Subject: [PATCH] Issue #16860: In tempfile, use O_CLOEXEC when available to set the close-on-exec flag atomically. --- Lib/tempfile.py | 2 ++ Misc/NEWS | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 90b3c20ac4f..0aaee541c3b 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'): diff --git a/Misc/NEWS b/Misc/NEWS index e63803960cb..284ce1a3bc5 100644 --- 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.