[comp.bugs.4bsd] rlogin -8 uses RAW rather than CBREAK mode

barmar@think (Barry Margolin) (12/21/90)

I ran into this problem on a Sun, but I notice that the 4.3bsd source has
the same thing.

Normally, rlogin puts the local terminal in CBREAK mode and disables all
the local control characters except the stop and start character (normally
^S and ^Q).  During the session it disables and enables these characters
when it receives TIOC_NOSTOP and TIOC_DOSTOP out-of-band messages from the
remote host.

However, when the "-8" option is supplied, rlogin instead puts the local
terminal in RAW mode, leaves ^S/^Q set as the stop/start characters, and
ignores the TIOC_DOSTOP and TIOC_NOSTOP messages.  This means that the
remote host must implement the stop/start processing.  Why should this be
dependent on 8-bit mode?  The only explanation I can think of is that 8-bit
mode was envisioned to support binary file transfers.  However, the remote
system will still have to disable stop/start, which will still result in
the out-of-band message, so there should be no problem.
--
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

casey@gauss.llnl.gov (Casey Leedom) (12/21/90)

| From: barmar@think (Barry Margolin)
| 
| Normally, rlogin puts the local terminal in CBREAK mode and disables all
| the local control characters except the stop and start character (normally
| ^S and ^Q).  During the session it disables and enables these characters
| when it receives TIOC_NOSTOP and TIOC_DOSTOP out-of-band messages from the
| remote host.
| 
| However, when the "-8" option is supplied, rlogin instead puts the local
| terminal in RAW mode, leaves ^S/^Q set as the stop/start characters, and
| ignores the TIOC_DOSTOP and TIOC_NOSTOP messages.  This means that the
| remote host must implement the stop/start processing.  Why should this be
| dependent on 8-bit mode?  The only explanation I can think of is that 8-bit
| mode was envisioned to support binary file transfers.  However, the remote
| system will still have to disable stop/start, which will still result in
| the out-of-band message, so there should be no problem.

  "-8" is used to implement an 8-bit transparent link.  Allowing START
and STOP character processing would defeat that purpose.  I use "-8" to
rlogin over from a terminal server and run a remote X server on a Sun
host for instance.  Normally "-8" should be used with out of band or no
flow control.

  It sounds like you have an application that generally wants to use
8-bits, but doesn't care if some STOP and some START characters are
sucked out of the data stream, and you don't have out of band flow
control capability, and you need some form of flow control.  Probably your
best bet is to implement a "-cbreak" flag ("-c" for dyed in the wool
single character Unix switch fans) to indicate that while you want LITOUT
and PASS8, you want it to use CBREAK rather than the more intuitive RAW.

Casey

barmar@think.com (Barry Margolin) (12/22/90)

In article <88236@lll-winken.LLNL.GOV> casey@gauss.llnl.gov (Casey Leedom) writes:
>  "-8" is used to implement an 8-bit transparent link.  

The documentation (on a MORE/4.3 system and a Sun) just says 8-bit; it says
nothing about transparency.

>							 Allowing START
>and STOP character processing would defeat that purpose.  I use "-8" to
>rlogin over from a terminal server and run a remote X server on a Sun
>host for instance.  Normally "-8" should be used with out of band or no
>flow control.

When you start the remote X server, doesn't it put the terminal in raw
mode?  That will cause rlogind to send the TIOC_NOSTOP command to rlogin,
which will cause it to disable the start and stop character processing.  At
this point you will have an 8-bit, transparent data path to the terminal.
Why would the purpose be defeated?

Actually, one possibility that has just occurred to me is that some people
might rlogin to a non-Unix host that doesn't actually have commands to
enable/disable flow control.  In fact, I once implemented an rlogin server
for such a host.  The right thing is for the server to send an immediate
TIOC_NOSTOP when the connection is first opened, since it's the one that
wants the transparent path.  Instead, this was put into the rlogin command
by overloading the -8 option.  If it must be in rlogin, it would probably
be better to have a separate -raw option.

>  It sounds like you have an application that generally wants to use
>8-bits, but doesn't care if some STOP and some START characters are
>sucked out of the data stream, and you don't have out of band flow
>control capability, and you need some form of flow control.

Yes.  I noticed this when using SunLink X.25.  We have a Sun that is
connected to all our dialup modems and an X.25 public network.  After
prompting for the user name and password it prompts for a host and executes
"rlogin -8 <host>"; we use -8 because some of our users have terminals with
meta keys that simply turn on the high-order bit, and Emacs recognizes this
use.  The X.25/X.29 protocol includes a mechanism for the host to tell the
PAD to perform XON/XOFF flow control, and I'd like to be able to use that
when the user is not in a raw-mode application such as Emacs
(single-character round-trip time in X.25 is not great).

>  Probably your
>best bet is to implement a "-cbreak" flag ("-c" for dyed in the wool
>single character Unix switch fans) to indicate that while you want LITOUT
>and PASS8, you want it to use CBREAK rather than the more intuitive RAW.

That's probably what I'll do.  I was mostly looking for warnings about
possible side-effects of the behavior that I wasn't aware of, and which
would be broken by such a mode.
--
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

chris@mimsy.umd.edu (Chris Torek) (12/24/90)

barmar@think (Barry Margolin) asks why -8 uses RAW, not CBREAK.

In article <88236@lll-winken.LLNL.GOV> casey@gauss.llnl.gov (Casey Leedom)
answers:
>  "-8" is used to implement an 8-bit transparent link.  Allowing START
>and STOP character processing would defeat that purpose. ..

Well, yes and no.  The real reason rlogin -8 uses RAW is that it was
coded under 4.2BSD, where raw mode was the only way to get 8 bits.
LPASS8 appeared in 4.3BSD (imported from Utah).

Now that 4BSD has a POSIXified tty driver, all of this should be redone.
But when the new ``bstreams'' code is working things may change again
anyway.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris