From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/
Date: Sun, 23 Jun 2013 22:57:15 +0000 (UTC) [thread overview]
Message-ID: <1372028218.76ebfcf74e09bf40bfc790bbc7a917d71a1a0c00.zmedico@gentoo> (raw)
commit: 76ebfcf74e09bf40bfc790bbc7a917d71a1a0c00
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 23 22:56:58 2013 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> 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/<pid>/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/<pid>/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/<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',):
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)
next reply other threads:[~2013-06-23 22:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-23 22:57 Zac Medico [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-11-17 17:43 [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/ Zac Medico
2013-11-29 23:24 Mike Frysinger
2013-06-25 7:48 Zac Medico
2013-06-23 22:40 Zac Medico
2013-02-11 9:39 Zac Medico
2013-01-19 5:16 Zac Medico
2013-01-19 5:00 Zac Medico
2013-01-19 3:23 Zac Medico
2013-01-19 3:23 Zac Medico
2013-01-19 2:27 Zac Medico
2013-01-19 1:53 Zac Medico
2012-10-18 0:05 Zac Medico
2012-03-17 16:44 Zac Medico
2012-03-11 1:40 Mike Frysinger
2011-12-08 7:26 Zac Medico
2011-06-17 22:35 Zac Medico
2011-06-04 1:39 Zac Medico
2011-02-20 0:00 Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372028218.76ebfcf74e09bf40bfc790bbc7a917d71a1a0c00.zmedico@gentoo \
--to=zmedico@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox