summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorAlexey Izbyshev <izbyshev@users.noreply.github.com>2018-02-20 07:25:46 (GMT)
committerBenjamin Peterson <benjamin@python.org>2018-02-20 07:25:46 (GMT)
commitb3caf388a0418f6c031e4dbdcc0c1ce7e5cc36bd (patch)
tree7025b2b4dbc38210b441ceb9b991c1ca6ade3a4d /Modules/posixmodule.c
parent6240917b773b52f8883387b9e3a5f327a4372068 (diff)
downloadcpython-b3caf388a0418f6c031e4dbdcc0c1ce7e5cc36bd.zip
cpython-b3caf388a0418f6c031e4dbdcc0c1ce7e5cc36bd.tar.gz
cpython-b3caf388a0418f6c031e4dbdcc0c1ce7e5cc36bd.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.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index d242df0..0bbf7c5 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -8016,7 +8016,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) {