Subject: Re: TTYs and 7E1
To: Jukka Marin <jmarin@teeri.jmp.fi>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: current-users
Date: 09/27/1995 11:30:49
> While I know next to nothing about these interfaces (well, I know how to
> use termios), I feel that fixing every single program using sgtty means
> too much work. Is there really NO way of changing the sgtty emulation (?)
> of NetBSD so that the vital charasteristics of the TTY lines (like the
> number of data bits, parity mode etc.) could be preserved even when a
> program uses sgtty?
Speaking as someone who implemented a translation scheme between sgtty and
a far richer terminal interface than termios: not really. The sgtty modes
have far too little state, and paint things with too broad a brush, to allow
reasonable mappings between anything usable and sgtty.
One thing that *can* be done to ameliorate the problem somewhat (which I did
under UNOS) is to keep a cache of terminal modes for a small number of file
descriptors, i.e. you can make
gtty(4, &oldstate);
newstate = oldstate;
/* damage newstate sorely */
stty(4, &newstate);
/* blah blah blah */
stty(4, &oldstate);
exactly restore the original modes, which is what you want in 90% of cases.
(Programs which aren't in that 90%, i.e. those which are really trying to
alter modes in some clever way and which "restore" the old state only by
coincidence, are prime candidates for conversion to TERMIOS anyway.)
Note that there are *many* ways for this to either fail to accomplish what
you want, or (worse) to accomplish something you _don't_ want, and that
debugging those cases can be tricky; you're trading off easing the port of
most programs for really hairing up the remainder.
Whoever spends their time chained to the TTY subsystem should probably give
this idea some consideration, but I certainly will be neither surprised nor
offended if it's dropped like the gross hack that it is ;-).