diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-04-02 05:53:03 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-04-02 05:53:03 +0000 |
commit | fa3a424e63ab923acd97889150690673c80290c1 (patch) | |
tree | 5e0d68ebeafe98008aee83b110ad02186cf56ec1 | |
parent | e23498f1ea6b50ae442d5a7f56224edc0d764d34 (diff) | |
download | portage-fa3a424e63ab923acd97889150690673c80290c1.tar.gz portage-fa3a424e63ab923acd97889150690673c80290c1.tar.bz2 portage-fa3a424e63ab923acd97889150690673c80290c1.zip |
Add a portage_exec.get_open_fds() function for bug #128284. Thanks to Brian Harring for this patch.
svn path=/main/trunk/; revision=3054
-rw-r--r-- | pym/portage_exec.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pym/portage_exec.py b/pym/portage_exec.py index 31b379396..e800376dc 100644 --- a/pym/portage_exec.py +++ b/pym/portage_exec.py @@ -17,6 +17,13 @@ try: except ImportError: max_fd_limit = 256 +if os.path.isdir("/proc/%i/fd" % os.getpid()): + def get_open_fds(): + return map(int, os.listdir("/proc/%i/fd" % os.getpid())) +else: + def get_open_fds(): + return xrange(max_fd_limit) + sandbox_capable = (os.path.isfile(SANDBOX_BINARY) and os.access(SANDBOX_BINARY, os.X_OK)) @@ -222,7 +229,7 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask): os.dup2(my_fds[fd], fd) # Then close _all_ fds that haven't been explictly # requested to be kept open. - for fd in range(max_fd_limit): + for fd in get_open_fds(): if fd not in my_fds: try: os.close(fd) |