Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!linus!decvax!harpo!seismo!hao!hplabs!sri-unix!moss@brl-vld
From: moss%brl-vld@sri-unix.UUCP
Newsgroups: net.unix
Subject: Re:  non-blocking read
Message-ID: <16702@sri-arpa.UUCP>
Date: Thu, 9-Feb-84 11:47:41 EST
Article-I.D.: sri-arpa.16702
Posted: Thu Feb  9 11:47:41 1984
Date-Received: Mon, 20-Feb-84 01:07:11 EST
Lines: 22

From:      Gary S Moss ~Software Development Team~ 

> if the program somehow exits after the "fcntl( 0, F_SETFL, O_NDELAY )",
> you will get spontaneously logged off.

Good point Dave.
When I first implemented the code, I didn't save the file status flags,
and got logged out immediately upon exiting.  Trapping interrupts is
a good idea in any program that does some sort of clean-up, I may have
left other details out in the attempt to be concise.  Opening /dev/tty
sounds like a good idea, I'll give it a try.

One thing I neglected to mention, is that after clearing the ICANON bit
in the termio structure, you will want to mask off the sign bit :

#define CMASK	0377
int	c;	/* Good idea using int if comparing to constants.	*/
	
	if( read( 0, (char *)&c, 1 ) )
		switch( c & CMASK )
		UP: ...
- Moss.