[ale] old school: pty and tty

cfowler cfowler at outpostsentinel.com
Fri Jan 31 15:54:53 EST 2003


On Fri, 2003-01-31 at 15:42, John Wells wrote:
> 
> Just saw a note on a google search that said the Stevens "Advanced
> Programming in a Unix Environment" book is the place to look for this. 
> I've got that on my shelf at home, so that's my next stop.

Okay all I haev to say is forget the price and spend it.  I have all of
Richard Steven's books.  Here is the list

1) Advanced Programming in the Unix Environment
2) Unix Network Programming vol 1
3) Unix Network Programming vol 2
4) TCP/IP Illustrated vol1
5) TCP/IP Illustrated vol2
6) TCP/IP Illustrated vol3


IMHO any serious unix programmer will have these or have read these.  I
have all 6 and total I believe they'll cost around $300.  These books
stay in mt permanent collection.


There is some good data in there and some example programs.  I'm not
sure if Richard goes over the pty89 not 98 like I had mentioned before
standard. 



I also have Linux Application Development.  This book is a good start
but focuses on  Linux.  Although there is not much difference between
Unix and Linux programming.

Although you can do some neat tricks in Linux

Run this as root:

int
main(int argc, char *argv[]) {
   iopl(3);
   outb(0c20, 0xFF);
}

It will lock up your box.  I was trying to do some lower level
programming and used a similar program to get values from the 8259 chip.



> 
> I appreciate the info.
> 
> John
> 
> cfowler said:
> > I can give you a slight overview.  But really the only way you can
> > experience the difference is to program for both.  Otherwise this is
> > just incomprehensible stuff.
> >
> > tty:
> >
> > Real tty.  I guess you can call this a serial port, virtual terminal,
> > etc.  These are devices that have some form of hardware attached to the
> > other end.  In the ttyS0 it is usually a 16C550 UART. For tty[0-?]. It
> > is a driver for video memory, keyboard and mouse.  On the serial side of
> > things you can modify the UART registers.  You do that with an ioctl()
> > command or the stty command which implements ioctl().  You can change
> > parameters such as speed, char size, bits, signal status, etc...  You
> > can modify the physical attributes of the hardware.
> >
> >
> > pty:
> >
> > Pseudo tty.  This is not a reall tty.  It is really a pipe with some
> > extra features.  It provides some of the POSIX services that a real tty
> > provide.  Like the ability of becoming a controlling tty, different read
> > modes.  Character attributes, etc.
> >
> > This device is really used when it comes to telnet, ssh, and other
> > network programs that provide a tty to the user.  In the past a user
> > wanted to communicate with a Unix box and login just as they are on a
> > serial terminal.  But instead of over the network.  So UNIX programmers
> > had to come up with a way to provide serial terminal like functions
> > without the hardware.
> >
> > Slave Vs Master:
> >
> > In pseudo tty's you have a slave and a master.  When you log into a
> > Linux box remotely and issue the tty command, the system will display
> > the slave.  As far as you are concerned, your STDIN, STDOUT, and STDERR
> > are all connected to the slave like /dev/ttyp0.  Signals and other
> > things coming down the line behave as if you were on a serial port.
> >
> > CTRL-C.  When you  type your CTRL-C on you keyboard, the app does not
> > see such a sequence.  The pty driver sees the CTRL-C then it signals
> > SIGINT to the process that is control of that slave.  This is where
> > controlling tty comes into play.
> >
> > The master:
> >
> > telnet really reads and writes to 2 file descriptors.  It will read from
> > the master (ptyp0) and write to the socket.  It will read from the
> > socker and write to the master (ptyp0).  The OS then passes that data
> > through preprocessing for control chars, etc then it send the data to
> > ttyp0 the slave.  That is how the relationship works.
> >
> > As you can see the only thing that makes a tty real is hardware on the
> > other end. And what makes a pseudo-tty is software.
> >
> > I have a POSIX.1 Spec guide which goes into detail on the requirments.
> > Or you can write some code.
> >
> >
> > On Fri, 2003-01-31 at 15:16, John Wells wrote:
> >> Anyone know any good links to explanations of the differences between
> >> pty and tty, or a good overview of each?
> >>
> >> Thanks,
> >> John
> >>
> >>
> >> _______________________________________________
> >> Ale mailing list
> >> Ale at ale.org
> >> http://www.ale.org/mailman/listinfo/ale
> >
> >
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://www.ale.org/mailman/listinfo/ale
> 
> 
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale


_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list