equal
deleted
inserted
replaced
|
1 This patch uses fdwalk(3c) to close file descriptors; as that function is not |
|
2 widely implemented, this is unsuitable for upstream. |
|
3 |
|
4 --- Python-3.5.0rc2/Modules/posixmodule.c.~1~ 2015-08-25 10:19:14.000000000 -0700 |
|
5 +++ Python-3.5.0rc2/Modules/posixmodule.c 2015-09-02 12:31:54.885953202 -0700 |
|
6 @@ -7781,6 +7781,19 @@ |
|
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 |
|
26 @@ -7797,11 +7810,13 @@ |
|
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; |