Use /proc/self/fd for solaris compat, bug #474536
authorZac Medico <zmedico@gentoo.org>
Tue, 25 Jun 2013 07:48:18 +0000 (00:48 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 25 Jun 2013 07:48:18 +0000 (00:48 -0700)
bin/helper-functions.sh
pym/portage/process.py

index eb6066f7ab4dd0fd017075cbfbfd8897738635db..ecd78c3f3eff566e038d710331a53d59deb07836 100644 (file)
@@ -77,9 +77,9 @@ __redirect_alloc_fd() {
                        # Need to provide the functionality ourselves.
                        local fd=10
                        local fddir=/dev/fd
-                       # Use /proc/<pid>/fd if available (/dev/fd
+                       # Prefer /proc/self/fd if available (/dev/fd
                        # doesn't work on solaris, see bug #474536).
-                       [[ -d /proc/${BASHPID}/fd ]] && fddir=/proc/${BASHPID}/fd
+                       [[ -d /proc/self/fd ]] && fddir=/proc/self/fd
                        while :; do
                                        # Make sure the fd isn't open.  It could be a char device,
                                        # or a symlink (possibly broken) to something else.
index 6969370d2398b423e7f21f3ea17cd4fe393f5916..7fdc1333a99bee5c78b3cc29c4a3c55fce87ea70 100644 (file)
@@ -31,15 +31,15 @@ except ImportError:
 if sys.hexversion >= 0x3000000:
        basestring = str
 
-for _fd_dir in ("/dev/fd", "/proc/self/fd"):
+# Prefer /proc/self/fd if available (/dev/fd
+# doesn't work on solaris, see bug #474536).
+for _fd_dir in ("/proc/self/fd", "/dev/fd"):
        if os.path.isdir(_fd_dir):
                break
        else:
                _fd_dir = None
 
-# Use /proc/<pid>/fd for SunOS (/dev/fd
-# doesn't work on solaris, see bug #474536).
-if _fd_dir is not None and platform.system() not in ('SunOS',):
+if _fd_dir is not None:
        def get_open_fds():
                return (int(fd) for fd in os.listdir(_fd_dir) if fd.isdigit())