[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

Alexey Izbyshev report at bugs.python.org
Sat Dec 26 04:20:51 EST 2020


Alexey Izbyshev <izbyshev at ispras.ru> added the comment:

> Using close_fds=False, subprocess can use posix_spawn() which is safer and faster than fork+exec. For example, on Linux, the glibc implements it as a function using vfork which is faster than fork if the parent allocated a lot of memory. On macOS, posix_spawn() is even a syscall.

On Linux, unless you care specifically about users with Python 3.10+ on older kernels, implementing support for closerange() syscall in subprocess would provide better net benefit. This is because (a) performance advantage of posix_spawn() is no longer relevant on Linux after bpo-35823 and (b) supporting closerange() would benefit even those users who still need close_fds=True.

----------
nosy: +izbyshev

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42738>
_______________________________________


More information about the Python-bugs-list mailing list