diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-07-28 22:52:37 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-07-28 22:52:37 +0000 |
commit | d24538b602c3cc6b2d22c25f333f3829bbc3cdc2 (patch) | |
tree | fc5ff4f28d01034c37b800ff640d9d78527916b7 /pym/portage.py | |
parent | e9885d4d54e315304ee648414703ecc70ae7f4e9 (diff) | |
download | portage-d24538b602c3cc6b2d22c25f333f3829bbc3cdc2.tar.gz portage-d24538b602c3cc6b2d22c25f333f3829bbc3cdc2.tar.bz2 portage-d24538b602c3cc6b2d22c25f333f3829bbc3cdc2.zip |
For bug #186876, fall back it os.pipe() if pty.openpty() fails. (trunk r7422)
svn path=/main/branches/2.1.2/; revision=7423
Diffstat (limited to 'pym/portage.py')
-rw-r--r-- | pym/portage.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pym/portage.py b/pym/portage.py index 077175654..1b97fa855 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2332,6 +2332,7 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero master_fd = None slave_fd = None fd_pipes_orig = None + got_pty = False if logfile: del keywords["logfile"] fd_pipes = keywords.get("fd_pipes") @@ -2340,10 +2341,16 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero elif 1 not in fd_pipes or 2 not in fd_pipes: raise ValueError(fd_pipes) from pty import openpty - master_fd, slave_fd = openpty() + try: + master_fd, slave_fd = openpty() + got_pty = True + except EnvironmentError, e: + writemsg("openpty failed: '%s'\n" % str(e), noiselevel=1) + del e + master_fd, slave_fd = os.pipe() fd_pipes.setdefault(0, sys.stdin.fileno()) fd_pipes_orig = fd_pipes.copy() - if os.isatty(fd_pipes_orig[1]): + if got_pty and os.isatty(fd_pipes_orig[1]): from output import get_term_size, set_term_size rows, columns = get_term_size() set_term_size(rows, columns, slave_fd) @@ -2398,7 +2405,7 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero if logfile: log_file = open(logfile, 'a') stdout_file = os.fdopen(os.dup(fd_pipes_orig[1]), 'w') - master_file = os.fdopen(master_fd, 'w+') + master_file = os.fdopen(master_fd, 'r') iwtd = [master_file] owtd = [] ewtd = [] |