bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-readline] Re: Readline on Mars, EXTPROC and rlwrap


From: Howard Chu
Subject: [Bug-readline] Re: Readline on Mars, EXTPROC and rlwrap
Date: Tue, 18 Jan 2011 01:37:20 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8pre) Gecko/20101024 Firefox/4.0b8pre SeaMonkey/2.1b2pre

Hans Lub wrote:
This is not about a bug, but a feature request:

Apparently the majority of the free software world uses high speed low latency networks and doesn't care about this issue. Certainly few people have contacted me with any interest in pursuing this further. I generated patches for readline, libedit, and OpenSSH but neither their maintainers nor any other users cared and the patches are probably bitrotted by now. I never anticipated that getting traction in the kernel was going to be the easiest part of this effort...

Suppose I ssh into a server on Mars. Whenever I press a key, I will
first see the echoed keystroke some 20 minutes later. Very unnerving!

Luckily, the sshd on Mars can put its pty in EXTPROC mode. Input line
editing (with backspace) and character echo are disabled by the tty
driver, and will now be done on Earth by the ssh client. (this is known
as LINEMODE, c.f. RFC 1116) The Martian client (say a shell) doesn't
have to know about this, but whenever it turns e.g. ECHO off this will
now actually change the behaviour of the Earthly client.

To do this, this client must of course know about the state (termios
structure) of the Martian pty. To make this possible, EXTPROC uses
packet mode, and a special packet (having a control byte with
TIOCPKT_IOCTL set) will communicate pty state changes (say by sending
the new termios structure to Earth)

Now we're at it, we might as well build readline into the ssh client
so that line editing becomes really comfortable. But here is a snag: if
the Martian shell uses readline itself, it will keep its terminal in
non-canonical mode all the time, so that we on Earth never get to know
that Mars is expecting entire lines from us.

Howard Chu, who submitted a patch to put EXTPROC in the linux tty
driver this summer, suggested that readline sense EXTPROC and would
behave like "gets with a prompt" in that case, keeping the terminal in
canonical mode, so that Earthlings can use the readline on their
side. He even submitted a (quick and dirty) patch for readline but I
cannot find any response to his submission.

The upcoming version of the readline wrapper rlwrap will also be able
to use EXTPROC, as it solves the long standing race condition where
rlwrapped command may change its terminal state and rlwrap will only
learn about that *after* the next keypress. Using EXTPROC, rlwrap will
be notified immediately by a packet with TIOCPKT_IOCTL.

If readline were "EXTPROC-aware" then one could transparently rlwrap
commands that use readline and have rlwrap do the line editing. This
can be useful when e.g. the command doesn't save its command history,
or if we prefer a coloured prompt.

I am not quite sure how widespread EXTPROC is. It used to be in BSD,
but was retired from FreeBSD in 2004, when they apparently lost all
faith in interplanetary travel. Linux never knew about it until summer
2010, when the spread of mobile internet made people sometimes wonder
whether the whole internet had suddenly relocated to Mars.

My question (after this long and winding story): wouldn't it be a good
idea to make readline EXTPROC-aware?

--
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]