Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Aug 2017 15:08:13 +0000
From:      bugzilla-noreply@freebsd.org
To:        python@FreeBSD.org
Subject:   [Bug 221700] lang/python: subprocess does not use closefrom, calls close(2) hundreds of thousands of times
Message-ID:  <bug-221700-21822-MVvunaW4Ux@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-221700-21822@https.bugs.freebsd.org/bugzilla/>
References:  <bug-221700-21822@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D221700

Conrad Meyer <cem@freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cem@freebsd.org

--- Comment #3 from Conrad Meyer <cem@freebsd.org> ---
You might also consider closefrom() in posix_closerange() of
Modules/posixmodule.c:

--- ./Modules/posixmodule.c     2015-05-23 09:09:20.000000000 -0700
+++ ./Modules/posixmodule.c     2015-07-17 15:00:38.784909475 -0700
@@ -6668,9 +6668,12 @@
     if (!PyArg_ParseTuple(args, "ii:closerange", &fd_from, &fd_to))
         return NULL;
     Py_BEGIN_ALLOW_THREADS
-    for (i =3D fd_from; i < fd_to; i++)
-        if (_PyVerify_fd(i))
-            close(i);
+    if (fd_to >=3D sysconf(_SC_OPEN_MAX)) {
+        closefrom(fd_from);
+    } else
+        for (i =3D fd_from; i < fd_to; i++)
+            if (_PyVerify_fd(i))
+                close(i);
     Py_END_ALLOW_THREADS
     Py_RETURN_NONE;
 }

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-221700-21822-MVvunaW4Ux>