summaryrefslogtreecommitdiff
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-04-28 15:39:24 -0700
committerZac Medico <zmedico@gentoo.org>2013-04-28 15:39:24 -0700
commit154e490e5064733a139eae72ed37192016dcb52f (patch)
treea1ec19b9268839be7f09cd04a909410b05d7d0f1 /pym
parentrepoman: add --include-arches, bug #466116 (diff)
downloadportage-154e490e5064733a139eae72ed37192016dcb52f.tar.gz
portage-154e490e5064733a139eae72ed37192016dcb52f.tar.bz2
portage-154e490e5064733a139eae72ed37192016dcb52f.zip
get_open_fds: use /dev/fd or /proc/self/fd
Since /dev/fd is supposed to be a fairly standard unix feature, try that first.
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/process.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/pym/portage/process.py b/pym/portage/process.py
index f00775cf5..24e347c26 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -30,10 +30,15 @@ except ImportError:
if sys.hexversion >= 0x3000000:
basestring = str
-if os.path.isdir("/proc/%i/fd" % os.getpid()):
+for _fd_dir in ("/dev/fd", "/proc/self/fd"):
+ if os.path.isdir(_fd_dir):
+ break
+ else:
+ _fd_dir = None
+
+if _fd_dir is not None:
def get_open_fds():
- return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) \
- if fd.isdigit())
+ return (int(fd) for fd in os.listdir(_fd_dir) if fd.isdigit())
if platform.python_implementation() == 'PyPy':
# EAGAIN observed with PyPy 1.8.