summaryrefslogtreecommitdiffstats
path: root/pym/portage/__init__.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-27 19:45:09 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-27 19:45:09 +0000
commit6bcbf5501d74819f078fb0b32cadccf15d3d2cfa (patch)
tree1f7d474538654058a58bdac1fde33462521b9a0d /pym/portage/__init__.py
parentbaa98e52b624fa40d6bc2e8c4ead269990bb3c05 (diff)
downloadportage-6bcbf5501d74819f078fb0b32cadccf15d3d2cfa.tar.gz
portage-6bcbf5501d74819f078fb0b32cadccf15d3d2cfa.tar.bz2
portage-6bcbf5501d74819f078fb0b32cadccf15d3d2cfa.zip
Make _test_pty_eof() use non-blocking IO, required for Darwin kernel.
svn path=/main/trunk/; revision=14449
Diffstat (limited to 'pym/portage/__init__.py')
-rw-r--r--pym/portage/__init__.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 67ab6b068..05f7b86bd 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -3746,7 +3746,7 @@ def _test_pty_eof():
Raises an EnvironmentError from openpty() if it fails.
"""
- import array, pty, termios
+ import array, fcntl, pty, select, termios
test_string = 2 * "blah blah blah\n"
test_string = _unicode_decode(test_string,
encoding='utf_8', errors='strict')
@@ -3757,6 +3757,10 @@ def _test_pty_eof():
master_file = os.fdopen(master_fd, 'rb')
slave_file = os.fdopen(slave_fd, 'wb')
+ # Non-blocking mode is required for Darwin kernel.
+ fcntl.fcntl(master_fd, fcntl.F_SETFL,
+ fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
+
# Disable post-processing of output since otherwise weird
# things like \n -> \r\n transformations may occur.
mode = termios.tcgetattr(slave_fd)
@@ -3771,9 +3775,17 @@ def _test_pty_eof():
eof = False
data = []
+ iwtd = [master_file]
+ owtd = []
+ ewtd = []
while not eof:
+ events = select.select(iwtd, owtd, ewtd)
+ if not events[0]:
+ eof = True
+ break
+
buf = array.array('B')
try:
buf.fromfile(master_file, 1024)