List Info

Thread: pty/termios problems on "alternative platforms"




pty/termios problems on "alternative platforms"
country flaguser name
Netherlands
2007-05-25 08:04:24
Hi,

Recently Portage's spawn code was changed to make use of pty
and
termios functions.  From [1] it sounds like using pty is
kind of
limited.  It seems to work fine on Linux and Darwin, IRIX I
assume so,
but on Solaris it does not.  I would be surpriced if it
would work on
AIX, not even thinking about Windows.  Anyhow, it seems
Python doesn't
raise an exception on the pty code, but only bails out on
the
termios.tcgetattr function because it gets an "invalid
argument".

Being not such a star in Python coding, but still requiring
Portage to
work on Solaris and AIX (and Windows), I'd like to reverse
the original
behaviour, but preferrably only when pty is not functional,
as I think
the current code is better.  Any suggestions for how to do
this at best?


[1] http://www.python.org/doc/1.5.2p2/lib/module-pty.html

-- 
Fabian Groffen
Gentoo on a different level
-- 
gentoo-portage-devgentoo.org mailing list


Re: pty/termios problems on "alternative platforms"
country flaguser name
Netherlands
2007-05-25 08:15:57
On 25-05-2007 15:04:24 +0200, Fabian Groffen wrote:
...
> raise an exception on the pty code, but only bails out
on the
> termios.tcgetattr function because it gets an
"invalid argument".

from the code pym/portage/__init__.py around line 2288

                from pty import openpty
                master_fd, slave_fd = openpty()
                # Disable the ECHO attribute so the terminal
behaves properly
                # if the subprocess needs to read input from
stdin.
                import termios
                term_attr = termios.tcgetattr(master_fd)
                term_attr[3] &= ~termios.ECHO
                termios.tcsetattr(master_fd,
termios.TCSAFLUSH, term_attr)

if I comment out the complete termios (last four lines) it
appears to
work, though I don't know what repercussions this has on the
rest of the
code.  Judging from the comment, it feels not so right.

-- 
Fabian Groffen
Gentoo on a different level
-- 
gentoo-portage-devgentoo.org mailing list


Re: pty/termios problems on "alternative platforms"
country flaguser name
United States
2007-05-25 14:44:10
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fabian Groffen wrote:
> On 25-05-2007 15:04:24 +0200, Fabian Groffen wrote:
> ...
>> raise an exception on the pty code, but only bails
out on the
>> termios.tcgetattr function because it gets an
"invalid argument".
> 
> from the code pym/portage/__init__.py around line 2288
> 
>                 from pty import openpty
>                 master_fd, slave_fd = openpty()
>                 # Disable the ECHO attribute so the
terminal behaves properly
>                 # if the subprocess needs to read input
from stdin.
>                 import termios
>                 term_attr =
termios.tcgetattr(master_fd)
>                 term_attr[3] &= ~termios.ECHO
>                 termios.tcsetattr(master_fd,
termios.TCSAFLUSH, term_attr)
> 
> if I comment out the complete termios (last four lines)
it appears to
> work, though I don't know what repercussions this has
on the rest of the
> code.  Judging from the comment, it feels not so
right.
> 

Try replacing master_fd with slave_fd in both the tcgetattr
and
tcsetattr calls.  I'm not sure if that will solve it but
it's worth
a try.

Zac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (GNU/Linux)

iD8DBQFGVzyJ/ejvha5XGaMRAgSRAJ9ugQK2FX4wKdbMjzUzvbyyjN/fsQCd
E+EF
lWenpj4ZAfWQ15Pq2pCwLp4=
=Rl1X
-----END PGP SIGNATURE-----
-- 
gentoo-portage-devgentoo.org mailing list


Re: pty/termios problems on "alternative platforms"
country flaguser name
Netherlands
2007-05-25 15:07:54
On 25-05-2007 12:44:10 -0700, Zac Medico wrote:
> > if I comment out the complete termios (last four
lines) it appears to
> > work, though I don't know what repercussions this
has on the rest of the
> > code.  Judging from the comment, it feels not so
right.
> 
> Try replacing master_fd with slave_fd in both the
tcgetattr and
> tcsetattr calls.  I'm not sure if that will solve it
but it's worth
> a try.

It lets it continue without a backtrace... so I guess that
sort of
works?


-- 
Fabian Groffen
Gentoo on a different level

-- 
gentoo-portage-devgentoo.org mailing list


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )