1 |
commit: 527726c8eee3b433bc0bd3453b2074ccbb823f89 |
2 |
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org> |
3 |
AuthorDate: Thu Jun 28 23:36:50 2012 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jun 29 12:50:24 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=527726c8 |
7 |
|
8 |
Partially synchronize WebappConfig.sandbox.get_open_fds() with portage.process.get_open_fds(). |
9 |
|
10 |
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org> |
11 |
|
12 |
--- |
13 |
WebappConfig/sandbox.py | 7 ++++++- |
14 |
1 files changed, 6 insertions(+), 1 deletions(-) |
15 |
|
16 |
diff --git a/WebappConfig/sandbox.py b/WebappConfig/sandbox.py |
17 |
index 0fddcce..88436c3 100644 |
18 |
--- a/WebappConfig/sandbox.py |
19 |
+++ b/WebappConfig/sandbox.py |
20 |
@@ -27,9 +27,14 @@ __version__ = "$Id: permissions.py 129 2005-11-06 12:46:31Z wrobel $" |
21 |
import os, os.path, sys |
22 |
|
23 |
# stolen from portage |
24 |
+try: |
25 |
+ import resource |
26 |
+ max_fd_limit = resource.getrlimit(resource.RLIMIT_NOFILE)[0] |
27 |
+except ImportError: |
28 |
+ max_fd_limit = 256 |
29 |
if os.path.isdir("/proc/%i/fd" % os.getpid()): |
30 |
def get_open_fds(): |
31 |
- return map(int, [fd for fd in os.listdir("/proc/%i/fd" % os.getpid()) if fd.isdigit()]) |
32 |
+ return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) if fd.isdigit()) |
33 |
else: |
34 |
def get_open_fds(): |
35 |
return range(max_fd_limit) |