Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Aug 1995 14:47:00 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        kelly@fsl.noaa.gov
Cc:        current@freebsd.org
Subject:   Re: bin/680: tip & termios problem
Message-ID:  <199508140447.OAA18575@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>Curiously enough, just clearing OPOST fixes the problem.
>...
>>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;

The sgttyb code simply set the RAW flag (and optionally the TANDEM flag)
so the new code should simply call cfmakeraw() (and optionally set the
IXOFF flag).  All the flag settings above (except the new c_oflag one :-)
are almost completely bogus:

1. Unseen flags are cleared unconditionally.  Termios flags shall be set
   using "|=" and cleared using "&=".
2. All the iflags and lflags that are set should actually be cleared (see
   the cfmakeraw()) source.
3. HUPCL probably shouldn't be changed here and CLOCAL certainly shouldn't
   be changed here.
4. CSIZE must be cleared when CS8 is set; PARENB should probably be cleared
   when CS8 is set.
5. PENDIN shouldn't be in c_lflag.  It isn't POSIX and shouldn't be changed
   by aplications, although cfmakeraw() clears it.
6. POSIXness of the source has little to do with POSIXness of the environment.
   Thus the application has to worry about warts like IMAXBEL (others like
   ECHOCTL and output flags are no problem because they are controlled by the
   standard flags ECHO and OPOST).  I usually use
   `#undef _POSIX_SOURCE ... #ifdef IMAXBEL ... c_iflag &= ~IMAXBEL'.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508140447.OAA18575>