From kelly@rose.rg.com  Sun Aug 13 08:08:52 1995
Received: from rose.rg.com (slip7.earthnet.net [199.45.146.107])
          by freefall.FreeBSD.org (8.6.11/8.6.6) with ESMTP id IAA26628
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 13 Aug 1995 08:08:47 -0700
Received: (from kelly@localhost) by rose.rg.com (8.6.11/8.6.9) id JAA07381; Sun, 13 Aug 1995 09:08:31 -0600
Message-Id: <199508131508.JAA07381@rose.rg.com>
Date: Sun, 13 Aug 1995 09:08:31 -0600
From: kelly@fsl.noaa.gov
Reply-To: kelly@fsl.noaa.gov
To: FreeBSD-gnats-submit@freebsd.org
Subject: tip & termios problem
X-Send-Pr-Version: 3.2

>Number:         680
>Category:       bin
>Synopsis:       2.0.5's tip using termios doesn't act the way it did with sgtty
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 13 08:10:01 PDT 1995
>Closed-Date:    Sun Apr 12 10:59:26 PDT 1998
>Last-Modified:  Sun Apr 12 10:59:35 PDT 1998
>Originator:     Sean Kelly
>Release:        FreeBSD 2.0-BUILT-19950603 i386
>Organization:
NOAA Forecast Systems Laboratory - Boulder, Colorado USA
>Environment:

Any FreeBSD 2.0.5 environment with a modem should do.

>Description:

Some time between 2.0 and 2.0.5, someone upgraded tip so it stopped
using the old sgtty interface and used termios instead.  In doing so,
tip's handling of special control characters sent by the remote host
got fouled.  The function in question was raw(), in tip.c.  If I
substituted the old sgtty stuff in this function only, tip acted
correctly, like the way it did before.

Not one to hinder progress, I wanted to find out what was different
between tip's use of the sgtty and termios interfaces.  After all, the
sgtty interface should just go to functions in /sys/kern/tty_compat.c,
which should transform them into termios-styled settings, right?

USING SGTTY, HERE ARE TERMIOS SETTINGS AFTER raw():

termios iflag = 0x401 (IGNBRK, IXOFF)
        oflag = 0x2 (ONLCR)
        cflag = 0xb00 (CREAD, CS8)
        lflag = 0x20000003 (ECHOKE, ECHOE, PENDIN)
termios cc = 00 00 0377 00 00 00 00 0377 00 00 00 00 00 00 00 00 01 00 0377 0377 
termios ispeed = 0, ospeed = 0


USING TERMIOS, HERE ARE TERMIOS SETTINGS AFTER raw():

termios iflag = 0x2a22 (BRKINT, ISTRIP, IXANY, IXON, IMAXBEL)
        oflag = 0x3  (ONLCR, OPOST)
        cflag = 0xcb00  (CREAD, CS8, CLOCAL, HUPCL)
        lflag = 0x200004c3 (ECHOE, ECHOKE, ISIG, ECHOCTL, IEXTEN, PENDIN)
termios cc = 04 0377 0377 0177 027 025 022 0377 0377 0377 0377 0377 021 023 0377 0377 01 00 0377 0377 
termios ispeed = 9600, ospeed = 9600


Curiously enough, just clearing OPOST fixes the problem.


>How-To-Repeat:

Run tip over a modem to your favorite host; there, run Emacs.  Edit
files, move around.  In almost no time, Emacs's status line will get
fouled.  Indentation on screen should also get cruddy on seemingly
random lines.

>Fix:
	
*** tip.c.orig	Fri Mar 31 04:47:30 1995
--- tip.c	Sun Aug 13 08:21:30 1995
***************
*** 219,227 ****
--- 219,229 ----
  #ifndef _POSIX_SOURCE
  	ctermios.c_iflag = (IMAXBEL|IXANY|ISTRIP|IXON|BRKINT);
  	ctermios.c_lflag = (PENDIN|IEXTEN|ISIG|ECHOCTL|ECHOE|ECHOKE);
+ 	ctermios.c_oflag &= ~OPOST;
  #else
  	ctermios.c_iflag = (ISTRIP|IXON|BRKINT);
  	ctermios.c_lflag = (PENDIN|IEXTEN|ISIG|ECHOE);
+ 	ctermios.c_oflag &= ~OPOST;
  #endif
  	ctermios.c_cflag = (CLOCAL|HUPCL|CREAD|CS8);
  	ctermios.c_cc[VINTR] = 	ctermios.c_cc[VQUIT] = -1;


>Release-Note:
>Audit-Trail:

From: J Wunsch <j@uriah.heep.sax.de>
To: kelly@fsl.noaa.gov
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/680: tip & termios problem
Date: Sun, 13 Aug 1995 19:12:32 +0200 (MET DST)

 As kelly@fsl.noaa.gov wrote:
 > 
 > Curiously enough, just clearing OPOST fixes the problem.
 > 
 > 
 > *** tip.c.orig	Fri Mar 31 04:47:30 1995
 > --- tip.c	Sun Aug 13 08:21:30 1995
 > ***************
 > *** 219,227 ****
 > --- 219,229 ----
 >   #ifndef _POSIX_SOURCE
 >   	ctermios.c_iflag = (IMAXBEL|IXANY|ISTRIP|IXON|BRKINT);
 >   	ctermios.c_lflag = (PENDIN|IEXTEN|ISIG|ECHOCTL|ECHOE|ECHOKE);
 > + 	ctermios.c_oflag &= ~OPOST;
 >   #else
 >   	ctermios.c_iflag = (ISTRIP|IXON|BRKINT);
 >   	ctermios.c_lflag = (PENDIN|IEXTEN|ISIG|ECHOE);
 > + 	ctermios.c_oflag &= ~OPOST;
 >   #endif
 >   	ctermios.c_cflag = (CLOCAL|HUPCL|CREAD|CS8);
 >   	ctermios.c_cc[VINTR] = 	ctermios.c_cc[VQUIT] = -1;
 
 Since the remaining c_fooflags are also set absolutely, it's perhaps
 best to set the oflag straight to 0 (the ONLCR does not have any
 effect if OPOST is cleared) instead.  Of course, RAW mode is supposed
 to not perform output postprocessing.
 
 -- 
 cheers, J"org
 
 joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/
 Never trust an operating system you don't have sources for. ;-)

From: kelly@fsl.noaa.gov (Sean Kelly)
To: joerg_wunsch@uriah.heep.sax.de
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/680: tip & termios problem
Date: Mon, 14 Aug 1995 10:06:59 -0600

 >>>>> "Joerg" == J Wunsch <j@uriah.heep.sax.de> writes:
 
     Joerg> Since the remaining c_fooflags are also set absolutely,
     Joerg> it's perhaps best to set the oflag straight to 0 
 
 Perhasp, although I don't like any of the absolute settings of any of
 the flags ... I've been bitten by that problem once too many times.
 
 -- 
 Sean Kelly
 NOAA Forecast Systems Lab, Boulder Colorado USA
 
 TASK: Shoot yourself in the foot.
 In Unix:
 % ls
 foot.c foot.h foot.o toe.c toe.o
 % rm * .o
 rm: .o: No such file or directory
 % ls
 %

From: J Wunsch <j@uriah.heep.sax.de>
To: kelly@fsl.noaa.gov (Sean Kelly)
Cc: joerg_wunsch@uriah.heep.sax.de, FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/680: tip & termios problem
Date: Mon, 14 Aug 1995 19:23:31 +0200 (MET DST)

 As Sean Kelly wrote:
 > 
 >     Joerg> Since the remaining c_fooflags are also set absolutely,
 >     Joerg> it's perhaps best to set the oflag straight to 0 
 > 
 > Perhasp, although I don't like any of the absolute settings of any of
 > the flags ... I've been bitten by that problem once too many times.
 
 See Bruce's reply...
 
 -- 
 cheers, J"org
 
 joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/
 Never trust an operating system you don't have sources for. ;-)
Responsible-Changed-From-To: freebsd-bugs->jkh 
Responsible-Changed-By: scrappy 
Responsible-Changed-When: Sun May 26 22:34:24 PDT 1996 
Responsible-Changed-Why:  
the person tha tbrought us the new tip 
Responsible-Changed-From-To: jkh->joerg 
Responsible-Changed-By: jkh 
Responsible-Changed-When: Sun Jun 2 21:43:51 PDT 1996 
Responsible-Changed-Why:  
Lateral pass to Joerg! :-) 
Responsible-Changed-From-To: joerg->freebsd-bugs 
Responsible-Changed-By: joerg 
Responsible-Changed-When: Tue Oct 21 00:11:45 MEST 1997 
Responsible-Changed-Why:  
I never understood why Jordan assigned this to me.  I'm not a tip user 
at all. 
Please, somebody who's actually using tip(1), have a look at it! 
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Sun Apr 12 10:59:26 PDT 1998 
State-Changed-Why:  
timed out 
>Unformatted:
