Path: utzoo!attcan!uunet!wugate!wuarchive!brutus.cs.uiuc.edu!tut.cis.ohio-state.edu!ucbvax!BRL.MIL!moss From: moss@BRL.MIL ("Gary S. Moss", VLD/VMB) Newsgroups: comp.sys.sgi Subject: Re: HELP: Low level terminal I/O Message-ID: <8907281005.aa01485@VMB.BRL.MIL> Date: 28 Jul 89 14:05:04 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 32 [Misha Pavel writes] < Is there any way to look at the system buffer and or return < from read() when no input was generated? Probably the better way to go, rather than mucking around with the terminal settings, is to use fcntl() as follows: Where fd is a file descriptor returned from creat(), open(), dup(), fcntl(), or pipe(). #include (void) fcntl( fd, F_SETFL, O_NDELAY ); /* to check the buffer... */ if( read( fd, bufptr, bytes ) == 0 ) ; /* nothing to read */ To be portable to BSD systems, the following is more correct: got = read( fd, bufptr, bytes); #ifdef BSD if( got == -1 && errno == EWOULDBLOCK ) got = 0; /* act like System V */ #endif if( got == 0 ) ; /* nothing to read */ Do a 'man fcntl' for more info. -moss