Python subprocess Default Behavior Change: Enhanced Performance, Balanced Security

2024-12-26

Python's subprocess module is changing its default behavior of closing all file descriptors. This change aims to improve performance, especially when dealing with a large number of file descriptors, avoiding performance bottlenecks caused by closing each descriptor individually. However, altering the default behavior could introduce security risks. Developers are advised to choose the `close_fds` parameter based on their specific needs and take appropriate security measures, such as ensuring all file descriptors are marked as non-inheritable. This change carefully balances performance and security, aiming to provide developers with a more flexible and efficient subprocess management solution.

Development