author | John Beck <John.Beck@Oracle.COM> |
Thu, 21 Jul 2016 12:52:32 -0700 | |
changeset 6447 | 56a2f066191a |
parent 5184 | 6c2a9525f3a4 |
child 7648 | 20e09cf3cfaa |
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 |
||
6447
56a2f066191a
23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents:
5184
diff
changeset
|
4 |
--- Python-3.5.2/Modules/posixmodule.c.~1~ 2016-06-25 14:38:38.000000000 -0700 |
56a2f066191a
23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents:
5184
diff
changeset
|
5 |
+++ Python-3.5.2/Modules/posixmodule.c 2016-07-08 06:58:01.808943682 -0700 |
56a2f066191a
23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents:
5184
diff
changeset
|
6 |
@@ -7779,6 +7779,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 |
|
6447
56a2f066191a
23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents:
5184
diff
changeset
|
26 |
@@ -7795,11 +7808,13 @@ |
4912 | 27 |
/*[clinic end generated code: output=70e6adb95220ba96 input=5855a3d053ebd4ec]*/ |
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; |