summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-02-21 05:21:12 (GMT)
committerBenjamin Peterson <benjamin@python.org>2018-02-21 05:21:12 (GMT)
commit16de2a9b8697cf90840eb217fb079f9c4c73e588 (patch)
tree9d2be73c1c562edb97d3494849ff795b030289d7 /Modules
parent76c3f5eeb07aeb037da1ed6761dd9bd95e2c1d8d (diff)
downloadcpython-16de2a9b8697cf90840eb217fb079f9c4c73e588.zip
cpython-16de2a9b8697cf90840eb217fb079f9c4c73e588.tar.gz
cpython-16de2a9b8697cf90840eb217fb079f9c4c73e588.tar.bz2
closes bpo-32859: Don't retry dup3() if it is not available at runtime (GH-5708)
os.dup2() tests for dup3() system call availability at runtime, but doesn't remember the result across calls, repeating the test on each call with inheritable=False. Since the caller of os.dup2() is expected to hold the GIL, fix this by making the variable holding the test result static. (cherry picked from commit b3caf388a0418f6c031e4dbdcc0c1ce7e5cc36bd) Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 85ec255..885c267 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7704,7 +7704,7 @@ os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable)
#if defined(HAVE_DUP3) && \
!(defined(HAVE_FCNTL_H) && defined(F_DUP2FD_CLOEXEC))
/* dup3() is available on Linux 2.6.27+ and glibc 2.9 */
- int dup3_works = -1;
+ static int dup3_works = -1;
#endif
if (fd < 0 || fd2 < 0)