author | John Beck <John.Beck@Oracle.COM> |
Mon, 06 Feb 2017 13:54:36 -0800 | |
changeset 7648 | 20e09cf3cfaa |
parent 6447 | 56a2f066191a |
permissions | -rw-r--r-- |
4912 | 1 |
This patch uses fdwalk(3c) to close file descriptors; as that function is not |
2 |
widely implemented, this is unsuitable for upstream. |
|
3 |
||
7648
20e09cf3cfaa
25429083 Upgrade Python 3.5 line to 3.5.3
John Beck <John.Beck@Oracle.COM>
parents:
6447
diff
changeset
|
4 |
--- Python-3.5.3/Modules/posixmodule.c.~1~ 2017-01-16 23:57:53.000000000 +0000 |
20e09cf3cfaa
25429083 Upgrade Python 3.5 line to 3.5.3
John Beck <John.Beck@Oracle.COM>
parents:
6447
diff
changeset
|
5 |
+++ Python-3.5.3/Modules/posixmodule.c 2017-01-17 11:14:01.793616905 +0000 |
20e09cf3cfaa
25429083 Upgrade Python 3.5 line to 3.5.3
John Beck <John.Beck@Oracle.COM>
parents:
6447
diff
changeset
|
6 |
@@ -7806,6 +7806,19 @@ |
4912 | 7 |
Py_RETURN_NONE; |
8 |
} |
|
9 |
||
10 |
+static int |
|
11 |
+close_func(void *lohi, int fd) |
|
12 |
+{ |
|
13 |
+ int lo = ((int *)lohi)[0]; |
|
14 |
+ int hi = ((int *)lohi)[1]; |
|
15 |
+ |
|
16 |
+ if (fd >= hi) |
|
17 |
+ return (1); |
|
18 |
+ else if (fd >= lo) |
|
19 |
+ close(fd); |
|
20 |
+ |
|
21 |
+ return (0); |
|
22 |
+} |
|
23 |
||
24 |
/*[clinic input] |
|
25 |
os.closerange |
|
7648
20e09cf3cfaa
25429083 Upgrade Python 3.5 line to 3.5.3
John Beck <John.Beck@Oracle.COM>
parents:
6447
diff
changeset
|
26 |
@@ -7822,11 +7835,13 @@ |
20e09cf3cfaa
25429083 Upgrade Python 3.5 line to 3.5.3
John Beck <John.Beck@Oracle.COM>
parents:
6447
diff
changeset
|
27 |
/*[clinic end generated code: output=0ce5c20fcda681c2 input=5855a3d053ebd4ec]*/ |
4912 | 28 |
{ |
29 |
int i; |
|
30 |
+ int lohi[2]; |
|
31 |
+ |
|
32 |
Py_BEGIN_ALLOW_THREADS |
|
33 |
_Py_BEGIN_SUPPRESS_IPH |
|
34 |
- for (i = fd_low; i < fd_high; i++) |
|
35 |
- if (_PyVerify_fd(i)) |
|
36 |
- close(i); |
|
37 |
+ lohi[0] = fd_low; |
|
38 |
+ lohi[1] = fd_high; |
|
39 |
+ fdwalk(close_func, lohi); |
|
40 |
_Py_END_SUPPRESS_IPH |
|
41 |
Py_END_ALLOW_THREADS |
|
42 |
Py_RETURN_NONE; |