[net.unix-wizards] Stty/Gtty on System III and PC/IX?

km@emory.UUCP (Ken Mandelberg) (03/28/85)

I am trying to understand the formal connection between
stty/gtty and system III. Here is my best guess, correct
me if I am wrong. Stty and Gtty  were system calls on
version 7 which had the same effect as TIOCSETP and
TIOCGETP ioctls. On System III, the tty driver changed
and this time there was no special system call to
duplicate the effect of the new ioctls.

However, to allow compatability with version 7, a library
routine for stty/gtty was supplied to allow old source to
still configure the tty with the old sgttyb structure.
I guess this because I see stty/gtty in programs with
code ifdefed for System III.

I don't have any vanilla System III documentation, but I
do have PC/IX. There is no mention that I can find in the
doc of stty/gtty emulation routines. There is however, a
sgtty.h in /usr/include with a sgttyb structure and
definitions for the TIOCs. When I try the TIOCGETP it just
fails. There is also a gtty.o in /usr/lib/lib2.a. I tried
resolving out of here and find that it needs externals that
are not in any of the libraries I find.

Anyway, my guess is that stty/gtty emulation was supplied
with System III but not documented. Then when ISC did the
PC/IX port they just left it undocumneted but didn't
make it work.

Comments?
-- 
Ken Mandelberg
Emory University
Dept of Math and CS
Atlanta, Ga 30322

{akgua,sb1,gatech,decvax}!emory!km   USENET
km@emory                      CSNET
km.emory@csnet-relay          ARPANET

guy@rlgvax.UUCP (Guy Harris) (04/01/85)

Well, "stty" and "gtty" were all you had on V6.  V7 added "ioctl", and
System III picked it up.  "stty" and "gtty" were provided as library
routines on V7, but I think the system calls were there, although no library
routine invoked them; "stty" did a TIOCSETP.  S3 provides "stty" and "gtty"
as system calls; the kernel code maps them into TIOCSETP and TIOCGETP.

HOWEVER, it's *not* doing a V7-style TIOCGETP/gtty or TIOCSETP/stty!  It's
doing a UNIX/TS 1.0 or PWB/UNIX 2.0 TIOCGETP/gtty or TIOCSETP/stty, which
is a horse of another color (and, by the lemma, that doesn't exist :-)).
You do NOT want to do "stty", "gtty", "ioctl(TIOCGETP)", or "ioctl(TIOCSETP)"
under System III if you can possibly avoid it.

System III comes from a different line of development than V7.  It is 95%
based on the same code as V7, but the tty driver developed differently.
It is backwards-compatible with UNIX/TS 1.0 and PWB/UNIX 2.0.

It is possible to replace the TS 1.0/PWB 2.0 compatibility stuff with
V7 compatibility stuff; it works about 95% of the time - RAW mode is the
only really nasty part, because RAW mode affects several different parts
of the "termio" structure, and does so in a non-invertable fashion.

	Guy Harris
	sun!guy (ignore any other addresses)

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (04/01/85)

Stty/gtty were system calls on all UNIXes for a long time.
Yes, they're effectively 7th Edition TIOCSETP/TIOCGETP ioctls.

When the new USG terminal driver was introduced, the stty/gtty
system calls were still supported (via emulation in the kernel)
for a transitional period.  This code was shipped as part of
the official Western Electric UNIX System III distributions.

I forget whether TIOCSETP/TIOCGETP ioctls (as opposed to stty/
gtty system calls) were ever supported by USG UNIX.  They may
have been in some versions as a 7th Edition compatibility measure.

If there is no stty() or gtty() in your C library, then it does
sound as though ISC decided to remove them for some reason (perhaps
to keep the kernel small).  You can write user-level emulations to
add to the C library; I have exactly the OPPOSITE emulation in
various UNIX System V emulations.  Better to just convert to the
new terminal handler and have done with it.

guy@rlgvax.UUCP (Guy Harris) (04/03/85)

> Stty/gtty were system calls on all UNIXes for a long time.
> Yes, they're effectively 7th Edition TIOCSETP/TIOCGETP ioctls.

Well, the V7 ones are, anyway; Sixth Edition UNIX had a different tty
driver (more like the one in UNIX/TS 1.0 and PWB/UNIX 2.0).

> I forget whether TIOCSETP/TIOCGETP ioctls (as opposed to stty/
> gtty system calls) were ever supported by USG UNIX.  They may
> have been in some versions as a 7th Edition compatibility measure.

The comment in the code reads "compatibility aide(sic) only".  Unfortunately
for those of us who have to deal with V7 but don't care about U/TS 1.0 or
PWB 2.0, they aren't backwards compatible with V7.  They can be made to
be 95-99% compatible, however.

	Guy Harris
	sun!guy

jsdy@hadron.UUCP (Joseph S. D. Yao) (04/11/85)

> I am trying to understand the formal connection between
> stty/gtty and system III.  ...
> sgtty.h in /usr/include with a sgttyb structure and
> definitions for the TIOCs. When I try the TIOCGETP it just
> fails. There is also a gtty.o in /usr/lib/lib2.a. I tried
> resolving out of here and find that it needs externals that
> are not in any of the libraries I find.

I don't find any mention of stty/gtty in S-III docs, either, and
am a bit puzzled why sgtty.h is even in your /usr/include.  As
you say, maybe S-III had it as an "invisible compatibility."
Anyway, the relevant ioctl's are in your tty(4) or termio(7) or
whatever version of the manual ... For S-III, they are TCGETA
and TCSETA.  The structure used is almost, but not completely,
unlike the sgtty structure.

If you only have (*shudder*) constants in your code (as 0174130),
you'll have to publish these, plus which system you guess the bits
are for, and you'll get upwards of a half dozen different answers
as to what the stty bits could/did/used to/do mean.

Do  n o t  use lib2.a in your code.  That's the subroutine library
for standalone programs!

	Joe Yao		hadron!jsdy@seismo.{ARPA,UUCP}