From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 9BA991381F3 for ; Sun, 23 Jun 2013 22:57:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 178EDE0712; Sun, 23 Jun 2013 22:57:18 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A21D0E0712 for ; Sun, 23 Jun 2013 22:57:17 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7F0A033E406 for ; Sun, 23 Jun 2013 22:57:16 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 275C9E468F for ; Sun, 23 Jun 2013 22:57:15 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1372028218.76ebfcf74e09bf40bfc790bbc7a917d71a1a0c00.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: bin/helper-functions.sh pym/portage/process.py X-VCS-Directories: bin/ pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 76ebfcf74e09bf40bfc790bbc7a917d71a1a0c00 X-VCS-Branch: master Date: Sun, 23 Jun 2013 22:57:15 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: b2ba6e93-57f8-449e-9761-11560ff704d5 X-Archives-Hash: 6045a004c5fec0e57eff4e2d4ad35967 commit: 76ebfcf74e09bf40bfc790bbc7a917d71a1a0c00 Author: Zac Medico gentoo org> AuthorDate: Sun Jun 23 22:56:58 2013 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Jun 23 22:56:58 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=76ebfcf7 Use /proc//fd for solaris compat, bug 474536 --- bin/helper-functions.sh | 6 +++++- pym/portage/process.py | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/helper-functions.sh b/bin/helper-functions.sh index 65f41f6..eb6066f 100644 --- a/bin/helper-functions.sh +++ b/bin/helper-functions.sh @@ -76,10 +76,14 @@ __redirect_alloc_fd() { else # Need to provide the functionality ourselves. local fd=10 + local fddir=/dev/fd + # Use /proc//fd if available (/dev/fd + # doesn't work on solaris, see bug #474536). + [[ -d /proc/${BASHPID}/fd ]] && fddir=/proc/${BASHPID}/fd while :; do # Make sure the fd isn't open. It could be a char device, # or a symlink (possibly broken) to something else. - if [[ ! -e /dev/fd/${fd} ]] && [[ ! -L /dev/fd/${fd} ]] ; then + if [[ ! -e ${fddir}/${fd} ]] && [[ ! -L ${fddir}/${fd} ]] ; then eval "exec ${fd}${redir}'${file}'" && break fi [[ ${fd} -gt 1024 ]] && die "__redirect_alloc_fd failed" diff --git a/pym/portage/process.py b/pym/portage/process.py index 7104552..6969370 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -37,7 +37,9 @@ for _fd_dir in ("/dev/fd", "/proc/self/fd"): else: _fd_dir = None -if _fd_dir is not None: +# Use /proc//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',): def get_open_fds(): return (int(fd) for fd in os.listdir(_fd_dir) if fd.isdigit()) @@ -52,6 +54,13 @@ if _fd_dir is not None: raise return range(max_fd_limit) +elif os.path.isdir("/proc/%s/fd" % os.getpid()): + # In order for this function to work in forked subprocesses, + # os.getpid() must be called from inside the function. + def get_open_fds(): + return (int(fd) for fd in os.listdir("/proc/%s/fd" % os.getpid()) + if fd.isdigit()) + else: def get_open_fds(): return range(max_fd_limit)