mirror of
https://github.com/python/cpython.git
synced 2025-10-01 12:52:18 +00:00
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 b3caf388a0
)
Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
This commit is contained in:
parent
a3d6c1b23b
commit
bab4fe320a
2 changed files with 3 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
In ``os.dup2``, don't check every call whether the ``dup3`` syscall exists
|
||||||
|
or not.
|
|
@ -8016,7 +8016,7 @@ os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable)
|
||||||
#if defined(HAVE_DUP3) && \
|
#if defined(HAVE_DUP3) && \
|
||||||
!(defined(HAVE_FCNTL_H) && defined(F_DUP2FD_CLOEXEC))
|
!(defined(HAVE_FCNTL_H) && defined(F_DUP2FD_CLOEXEC))
|
||||||
/* dup3() is available on Linux 2.6.27+ and glibc 2.9 */
|
/* dup3() is available on Linux 2.6.27+ and glibc 2.9 */
|
||||||
int dup3_works = -1;
|
static int dup3_works = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fd < 0 || fd2 < 0) {
|
if (fd < 0 || fd2 < 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue