How to programm TTY devices under UNIX platform?

There is the old unix way to do this and the new posix way. I wrote a program to put the tty into raw mode using both methods so I could compare them. You should probably understand both techniques since there is a lot of old code out there. But I think the posix revision is a win, so I would suggest going the posix route with new code. I would add the following man pages to your list:

tcattribute(3c)
cfspeed(3C)
tccontrol(3C)

You should use the routines in cfspeed(3C) to change the baud rate.

Here is the sample program that I wrote:

/*   #define OLD_TERMIO  */

#ifdef __STDC__
#define PROTOTYPICAL
#endif
#ifdef __cplusplus
#define PROTOTYPICAL
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#ifdef OLD_TERMIO
#include <termio.h>
#else
#include <termios.h>
#endif

#ifdef PROTOTYPICAL
int main(int argc, char *argv[])
#else
main(argc,argv)
char *argv[];
#endif

{
#ifdef OLD_TERMIO
        struct termio orig,now;
#else
        struct termios orig,now;
#endif
        int c, i, rc, done;
        setvbuf(stdout, NULL, _IONBF ,0);

#ifdef OLD_TERMIO
        ioctl(0, TCGETA, (char *) &orig);
#else
        tcgetattr(0, &orig);
#endif
        now=orig;
        now.c_lflag &= ~(ISIG|ICANON|ECHO);
        now.c_cc[VMIN]=1;
        now.c_cc[VTIME]=2;
#ifdef OLD_TERMIO
        ioctl(0,TCSETA, (char *) &now);
#else
        tcsetattr(0, TCSANOW, &now);
#endif
        done=0;
        while(!done) {
                printf("hit a key: ");
                c=getchar();
                printf(" got a  %03X \n", c);
                done = c=='q';
        }
#ifdef OLD_TERMIO
        ioctl(0,TCSETA, (char *) &orig);
#else
        tcsetattr(0, TCSANOW, &orig);
#endif
        exit(0);
}