View | Details | Raw Unified | Return to bug 242274 | Differences between
and this patch

Collapse All | Expand All

(-)lang/python27/Makefile (+1 lines)
Lines 2-7 Link Here
2
2
3
PORTNAME=	python
3
PORTNAME=	python
4
PORTVERSION=	${PYTHON_PORTVERSION}
4
PORTVERSION=	${PYTHON_PORTVERSION}
5
PORTREVISION=	1
5
CATEGORIES=	lang python
6
CATEGORIES=	lang python
6
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
7
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
7
PKGNAMESUFFIX=	27
8
PKGNAMESUFFIX=	27
(-)lang/python27/files/patch-Modules_posixmodule.c (+19 lines)
Line 0 Link Here
1
--- Modules/posixmodule.c.orig	2019-11-27 22:47:11 UTC
2
+++ Modules/posixmodule.c
3
@@ -6676,9 +6676,13 @@ posix_closerange(PyObject *self, PyObject *args)
4
     if (!PyArg_ParseTuple(args, "ii:closerange", &fd_from, &fd_to))
5
         return NULL;
6
     Py_BEGIN_ALLOW_THREADS
7
-    for (i = fd_from; i < fd_to; i++)
8
-        if (_PyVerify_fd(i))
9
-            close(i);
10
+    if (fd_to >= sysconf(_SC_OPEN_MAX)) {
11
+        closefrom(fd_from);
12
+    } else {
13
+        for (i = fd_from; i < fd_to; i++)
14
+            if (_PyVerify_fd(i))
15
+                close(i);
16
+    }
17
     Py_END_ALLOW_THREADS
18
     Py_RETURN_NONE;
19
 }
(-)lang/python35/Makefile (-1 / +1 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	python
4
PORTNAME=	python
5
PORTVERSION=	${PYTHON_PORTVERSION}
5
PORTVERSION=	${PYTHON_PORTVERSION}
6
PORTREVISION=	2
6
PORTREVISION=	3
7
CATEGORIES=	lang python
7
CATEGORIES=	lang python
8
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
8
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
9
PKGNAMESUFFIX=	${PYTHON_SUFFIX}
9
PKGNAMESUFFIX=	${PYTHON_SUFFIX}
(-)lang/python35/files/patch-Modules___posixsubprocess.c (+17 lines)
Line 0 Link Here
1
--- Modules/_posixsubprocess.c.orig	2019-11-27 23:01:59 UTC
2
+++ Modules/_posixsubprocess.c
3
@@ -233,8 +233,12 @@ _close_fds_by_brute_force(long start_fd, PyObject *py_
4
         start_fd = keep_fd + 1;
5
     }
6
     if (start_fd <= end_fd) {
7
-        for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
8
-            close(fd_num);
9
+        if (end_fd >= sysconf(_SC_OPEN_MAX)) {
10
+            closefrom(start_fd);
11
+        } else {
12
+            for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
13
+                close(fd_num);
14
+            }
15
         }
16
     }
17
 }
(-)lang/python35/files/patch-Modules_posixmodule.c (+19 lines)
Line 0 Link Here
1
--- Modules/posixmodule.c.orig	2019-11-27 23:03:12 UTC
2
+++ Modules/posixmodule.c
3
@@ -7853,9 +7853,13 @@ os_closerange_impl(PyObject *module, int fd_low, int f
4
     int i;
5
     Py_BEGIN_ALLOW_THREADS
6
     _Py_BEGIN_SUPPRESS_IPH
7
-    for (i = fd_low; i < fd_high; i++)
8
-        if (_PyVerify_fd(i))
9
-            close(i);
10
+    if (fd_high >= sysconf(_SC_OPEN_MAX)) {
11
+        closefrom(fd_low);
12
+    } else {
13
+        for (i = fd_low; i < fd_high; i++)
14
+            if (_PyVerify_fd(i))
15
+                close(i);
16
+    }
17
     _Py_END_SUPPRESS_IPH
18
     Py_END_ALLOW_THREADS
19
     Py_RETURN_NONE;
(-)lang/python36/Makefile (+1 lines)
Lines 3-8 Link Here
3
3
4
PORTNAME=	python
4
PORTNAME=	python
5
PORTVERSION=	${PYTHON_PORTVERSION}
5
PORTVERSION=	${PYTHON_PORTVERSION}
6
PORTREVISION=	1
6
CATEGORIES=	lang python
7
CATEGORIES=	lang python
7
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
8
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
8
PKGNAMESUFFIX=	${PYTHON_SUFFIX}
9
PKGNAMESUFFIX=	${PYTHON_SUFFIX}
(-)lang/python36/files/patch-Modules___posixsubprocess.c (+17 lines)
Line 0 Link Here
1
--- Modules/_posixsubprocess.c.orig	2019-07-02 20:25:39 UTC
2
+++ Modules/_posixsubprocess.c
3
@@ -236,8 +236,12 @@ _close_fds_by_brute_force(long start_fd, PyObject *py_
4
         start_fd = keep_fd + 1;
5
     }
6
     if (start_fd <= end_fd) {
7
-        for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
8
-            close(fd_num);
9
+        if (end_fd >= sysconf(_SC_OPEN_MAX)) {
10
+            closefrom(start_fd);
11
+        } else {
12
+            for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
13
+                close(fd_num);
14
+            }
15
         }
16
     }
17
 }
(-)lang/python36/files/patch-Modules_posixmodule.c (+18 lines)
Line 0 Link Here
1
--- Modules/posixmodule.c.orig	2019-07-02 20:25:39 UTC
2
+++ Modules/posixmodule.c
3
@@ -7685,8 +7685,13 @@ os_closerange_impl(PyObject *module, int fd_low, int f
4
     int i;
5
     Py_BEGIN_ALLOW_THREADS
6
     _Py_BEGIN_SUPPRESS_IPH
7
-    for (i = Py_MAX(fd_low, 0); i < fd_high; i++)
8
-        close(i);
9
+    fd_low = Py_MAX(fd_low, 0);
10
+    if (fd_high >= sysconf(_SC_OPEN_MAX)) {
11
+        closefrom(fd_low);
12
+    } else {
13
+        for (i = fd_low; i < fd_high; i++)
14
+            close(i);
15
+    }
16
     _Py_END_SUPPRESS_IPH
17
     Py_END_ALLOW_THREADS
18
     Py_RETURN_NONE;
(-)lang/python37/Makefile (+1 lines)
Lines 3-8 Link Here
3
3
4
PORTNAME=	python
4
PORTNAME=	python
5
PORTVERSION=	${PYTHON_PORTVERSION}
5
PORTVERSION=	${PYTHON_PORTVERSION}
6
PORTREVISION=	1
6
CATEGORIES=	lang python
7
CATEGORIES=	lang python
7
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
8
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
8
PKGNAMESUFFIX=	${PYTHON_SUFFIX}
9
PKGNAMESUFFIX=	${PYTHON_SUFFIX}
(-)lang/python37/files/patch-Modules___posixsubprocess.c (+17 lines)
Line 0 Link Here
1
--- Modules/_posixsubprocess.c.orig	2019-07-02 20:25:39 UTC
2
+++ Modules/_posixsubprocess.c
3
@@ -236,8 +236,12 @@ _close_fds_by_brute_force(long start_fd, PyObject *py_
4
         start_fd = keep_fd + 1;
5
     }
6
     if (start_fd <= end_fd) {
7
-        for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
8
-            close(fd_num);
9
+        if (end_fd >= sysconf(_SC_OPEN_MAX)) {
10
+            closefrom(start_fd);
11
+        } else {
12
+            for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
13
+                close(fd_num);
14
+            }
15
         }
16
     }
17
 }
(-)lang/python37/files/patch-Modules_posixmodule.c (+18 lines)
Line 0 Link Here
1
--- Modules/posixmodule.c.orig	2019-07-02 20:25:39 UTC
2
+++ Modules/posixmodule.c
3
@@ -7685,8 +7685,13 @@ os_closerange_impl(PyObject *module, int fd_low, int f
4
     int i;
5
     Py_BEGIN_ALLOW_THREADS
6
     _Py_BEGIN_SUPPRESS_IPH
7
-    for (i = Py_MAX(fd_low, 0); i < fd_high; i++)
8
-        close(i);
9
+    fd_low = Py_MAX(fd_low, 0);
10
+    if (fd_high >= sysconf(_SC_OPEN_MAX)) {
11
+        closefrom(fd_low);
12
+    } else {
13
+        for (i = fd_low; i < fd_high; i++)
14
+            close(i);
15
+    }
16
     _Py_END_SUPPRESS_IPH
17
     Py_END_ALLOW_THREADS
18
     Py_RETURN_NONE;
(-)lang/python38/Makefile (-1 / +1 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	python
4
PORTNAME=	python
5
PORTVERSION=	${PYTHON_PORTVERSION}
5
PORTVERSION=	${PYTHON_PORTVERSION}
6
PORTREVISION=	1
6
PORTREVISION=	2
7
CATEGORIES=	lang python
7
CATEGORIES=	lang python
8
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
8
MASTER_SITES=	PYTHON/ftp/python/${PORTVERSION}
9
PKGNAMESUFFIX=	${PYTHON_SUFFIX}
9
PKGNAMESUFFIX=	${PYTHON_SUFFIX}
(-)lang/python38/files/patch-Modules___posixsubprocess.c (+17 lines)
Line 0 Link Here
1
--- Modules/_posixsubprocess.c.orig	2019-07-02 20:25:39 UTC
2
+++ Modules/_posixsubprocess.c
3
@@ -236,8 +236,12 @@ _close_fds_by_brute_force(long start_fd, PyObject *py_
4
         start_fd = keep_fd + 1;
5
     }
6
     if (start_fd <= end_fd) {
7
-        for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
8
-            close(fd_num);
9
+        if (end_fd >= sysconf(_SC_OPEN_MAX)) {
10
+            closefrom(start_fd);
11
+        } else {
12
+            for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
13
+                close(fd_num);
14
+            }
15
         }
16
     }
17
 }
(-)lang/python38/files/patch-Modules_posixmodule.c (+18 lines)
Line 0 Link Here
1
--- Modules/posixmodule.c.orig	2019-10-14 13:34:47 UTC
2
+++ Modules/posixmodule.c
3
@@ -8460,8 +8460,13 @@ os_closerange_impl(PyObject *module, int fd_low, int f
4
     lohi[1] = fd_high;
5
     fdwalk(_fdwalk_close_func, lohi);
6
 #else
7
-    for (i = Py_MAX(fd_low, 0); i < fd_high; i++)
8
-        close(i);
9
+    fd_low = Py_MAX(fd_low, 0);
10
+    if (fd_high >= sysconf(_SC_OPEN_MAX)) {
11
+        closefrom(fd_low);
12
+    } else {
13
+        for (i = fd_low; i < fd_high; i++)
14
+            close(i);
15
+    }
16
 #endif
17
     _Py_END_SUPPRESS_IPH
18
     Py_END_ALLOW_THREADS

Return to bug 242274