[Bug 221700] lang/python: subprocess does not use closefrom, calls close(2) hundreds of thousands of times

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Aug 22 13:25:52 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221700

--- Comment #2 from Ed Maste <emaste at freebsd.org> ---
A minimum viable patch to address this:

diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 8c8777cfe3..d390ec8ee6 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -232,9 +232,13 @@ _close_fds_by_brute_force(long start_fd, PyObject
*py_fds_to_keep)
         start_fd = keep_fd + 1;
     }
     if (start_fd <= end_fd) {
+#if defined(__FreeBSD__)
+        closefrom(start_fd);
+#else
         for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
             close(fd_num);
         }
+#endif
     }
 }

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-python mailing list