python27: use absolute path to dtrace(8)
[unleashed-userland.git] / components / python / python27 / patches / 11-closerange.patch
blobe81a8be3e2c0639385fd3bc7411455240d057fb1
1 --- Python-2.7.6/Modules/posixmodule.c.~1~ 2013-11-09 23:36:41.000000000 -0800
2 +++ Python-2.7.6/Modules/posixmodule.c 2014-05-14 13:22:52.461187524 -0700
3 @@ -6603,16 +6603,34 @@
4 "closerange(fd_low, fd_high)\n\n\
5 Closes all file descriptors in [fd_low, fd_high), ignoring errors.");
7 +static int
8 +close_func(void *lohi, int fd)
9 +{
10 + int lo = ((int *)lohi)[0];
11 + int hi = ((int *)lohi)[1];
13 + if (fd >= hi)
14 + return (1);
15 + else if (fd >= lo)
16 + close(fd);
18 + return (0);
21 static PyObject *
22 posix_closerange(PyObject *self, PyObject *args)
24 int fd_from, fd_to, i;
25 + int lohi[2];
27 if (!PyArg_ParseTuple(args, "ii:closerange", &fd_from, &fd_to))
28 return NULL;
29 Py_BEGIN_ALLOW_THREADS
30 - for (i = fd_from; i < fd_to; i++)
31 - if (_PyVerify_fd(i))
32 - close(i);
34 + lohi[0] = fd_from;
35 + lohi[1] = fd_to;
36 + fdwalk(close_func, lohi);
38 Py_END_ALLOW_THREADS
39 Py_RETURN_NONE;