Don't restrict ourselves to a "max" fd when closing fds before exec() · pythoncapi/cpython@d4dcb70 · GitHub
Skip to content

Commit d4dcb70

Browse files
committed
Don't restrict ourselves to a "max" fd when closing fds before exec()
when we have a way to get an actual list of all open fds from the OS. Fixes issue python#21618: The subprocess module would ignore fds that were inherited by the calling process and already higher than POSIX resource limits would otherwise allow. On systems with a functioning /proc/self/fd or /dev/fd interface the max is now ignored and all fds are closed.
1 parent 694c315 commit d4dcb70

3 files changed

Lines changed: 102 additions & 43 deletions

File tree

Lib/test/test_subprocess.py

Lines changed: 53 additions & 0 deletions

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ Core and Builtins
1818
Library
1919
-------
2020

21+
- Issue #21618: The subprocess module could fail to close open fds that were
22+
inherited by the calling process and already higher than POSIX resource
23+
limits would otherwise allow. On systems with a functioning /proc/self/fd
24+
or /dev/fd interface the max is now ignored and all fds are closed.
25+
2126
- Issue #21552: Fixed possible integer overflow of too long string lengths in
2227
the tkinter module on 64-bit platforms.
2328

Modules/_posixsubprocess.c

Lines changed: 44 additions & 43 deletions

0 commit comments

Comments
 (0)